Merge branch 'picfmt-fixes' into 'next'

Fix a crash in Picture_GetPatchPixel with PICFMT_DOOMPATCH formats

See merge request STJr/SRB2!1324
This commit is contained in:
James R 2020-12-15 20:55:52 -05:00
commit f9ce70a6b3
2 changed files with 6 additions and 5 deletions

View File

@ -544,21 +544,22 @@ void *Picture_GetPatchPixel(
UINT16 *s16 = NULL;
UINT32 *s32 = NULL;
softwarepatch_t *doompatch = (softwarepatch_t *)patch;
boolean isdoompatch = Picture_IsDoomPatchFormat(informat);
INT16 width;
if (patch == NULL)
I_Error("Picture_GetPatchPixel: patch == NULL");
width = (Picture_IsDoomPatchFormat(informat) ? patch->width : SHORT(patch->width));
width = (isdoompatch ? SHORT(doompatch->width) : patch->width);
if (x >= 0 && x < width)
{
INT32 colx = (flags & PICFLAGS_XFLIP) ? (width-1)-x : x;
INT32 topdelta, prevdelta = -1;
INT32 colofs = (Picture_IsDoomPatchFormat(informat) ? LONG(patch->columnofs[colx]) : patch->columnofs[colx]);
INT32 colofs = (isdoompatch ? LONG(doompatch->columnofs[colx]) : patch->columnofs[colx]);
// Column offsets are pointers so no casting required
if (Picture_IsDoomPatchFormat(informat))
// Column offsets are pointers, so no casting is required.
if (isdoompatch)
column = (column_t *)((UINT8 *)doompatch + colofs);
else
column = (column_t *)((UINT8 *)patch->columns + colofs);

View File

@ -604,7 +604,7 @@ void *R_GetLevelFlat(levelflat_t *levelflat)
levelflat->height = ds_flatheight = SHORT(patch->height);
levelflat->picture = Z_Malloc(levelflat->width * levelflat->height, PU_LEVEL, NULL);
converted = Picture_FlatConvert(PICFMT_DOOMPATCH, patch, PICFMT_FLAT, 0, &size, levelflat->width, levelflat->height, patch->topoffset, patch->leftoffset, 0);
converted = Picture_FlatConvert(PICFMT_DOOMPATCH, patch, PICFMT_FLAT, 0, &size, levelflat->width, levelflat->height, SHORT(patch->topoffset), SHORT(patch->leftoffset), 0);
M_Memcpy(levelflat->picture, converted, size);
Z_Free(converted);
}