Avoid reading or writing savegame specdata arrays when the pointer to one is NULL or their count is zero.

git-svn-id: https://svn.eduke32.com/eduke32@5112 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2015-03-29 02:40:27 +00:00
parent 9cf7da4366
commit d5e3262a74

View file

@ -579,6 +579,9 @@ static uint8_t *writespecdata(const dataspec_t *spec, FILE *fil, uint8_t *dump)
ds_get(sp, &ptr, &cnt);
if (cnt < 0) { OSD_Printf("wsd: cnt=%d, f=0x%x.\n",cnt,sp->flags); continue; }
if (!ptr || !cnt)
continue;
if (fil)
{
if (((sp->flags&DS_CNTMASK)==0 && sp->size*cnt<=savegame_comprthres)
@ -644,6 +647,9 @@ static int32_t readspecdata(const dataspec_t *spec, int32_t fil, uint8_t **dumpv
ds_get(sp, &ptr, &cnt);
if (cnt < 0) { OSD_Printf("rsd: cnt<0... wtf?\n"); return -1; }
if (!ptr || !cnt)
continue;
if (fil>=0)
{
mem = (dump && (sp->flags&DS_NOCHK)==0) ? dump : (uint8_t *)ptr;