Commit f9ce70a6 by James R.

Merge branch 'picfmt-fixes' into 'next'

Fix a crash in Picture_GetPatchPixel with PICFMT_DOOMPATCH formats See merge request !1324
parents 019082cf 7e0a1709
......@@ -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);
......
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment