fix some null pointer dereferences
and enable -Wnull-dereference by default
This commit is contained in:
1 parent
1b0c6d9c03
commit
c8b4aa656b
4 files changed
+27
-6
No files matched your search
@@ -20,7 +20,7 @@ $(foreach v,$(join $(wordlist 2,$(_n),- $(gcc_versions)),\
|
||||
CXXFLAGS+= -Wno-aggregate-return
|
||||
|
||||
# -W -Wno-unused
|
||||
WFLAGS:=-Wall -Wno-trigraphs -Wshadow
|
||||
WFLAGS:=-Wall -Wno-trigraphs -Wshadow -Wnull-dereference
|
||||
ifndef GCC295
|
||||
#WFLAGS+=-Wno-packed
|
||||
endif
|
||||
|
||||
+5
-4
@@ -1346,14 +1346,15 @@ void M_MinimapGenerate(void)
|
||||
minigen = AM_MinimapGenerate(mul);
|
||||
|
||||
if (minigen == NULL || minigen->buf == NULL)
|
||||
goto failure;
|
||||
{
|
||||
CONS_Alert(CONS_ERROR, M_GetText("Couldn't create %s\n"), filepath);
|
||||
return;
|
||||
}
|
||||
|
||||
M_CreateScreenShotPalette();
|
||||
ret = M_SavePNG(filepath, minigen->buf, minigen->w, minigen->h, screenshot_palette);
|
||||
|
||||
failure:
|
||||
if (minigen->buf != NULL)
|
||||
free(minigen->buf);
|
||||
free(minigen->buf);
|
||||
|
||||
if (ret)
|
||||
{
|
||||
|
||||
@@ -1495,6 +1495,9 @@ musicdef_t *S_FindMusicCredit(const char *musname)
|
||||
{
|
||||
def = S_GetMusicCredit(i);
|
||||
|
||||
if (!def)
|
||||
continue;
|
||||
|
||||
if (hash != def->hash)
|
||||
continue;
|
||||
|
||||
|
||||
+18
-1
@@ -2011,6 +2011,9 @@ void *W_CachePatchNameRotated(const char *name, INT32 rotationangle, INT32 tag)
|
||||
|
||||
rspr = static_cast<rotsprite_t *>(W_GetCachedRotPatchPwad(WADFILENUM(num), LUMPNUM(num)));
|
||||
|
||||
if (rspr == NULL)
|
||||
return W_CachePatchNum(W_GetNumForName("MISSING"), tag);
|
||||
|
||||
if (rspr->patches[idx] == NULL)
|
||||
{
|
||||
INT32 xpivot = 0, ypivot = 0;
|
||||
@@ -2626,6 +2629,9 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum)
|
||||
|
||||
// Remember that we're assuming that the WAD will have a specific set of lumps in a specific order.
|
||||
UINT8 *wadData = static_cast<UINT8 *>(W_CacheLumpNum(lumpnum, PU_LEVEL));
|
||||
if (wadData == NULL)
|
||||
I_Error("vres_GetMap: Invalid WadData!\n");
|
||||
|
||||
filelump_t *fileinfo = reinterpret_cast<filelump_t *>(wadData + LONG((reinterpret_cast<wadinfo_t *>(wadData))->infotableofs));
|
||||
|
||||
i = LONG((reinterpret_cast<wadinfo_t *>(wadData))->numlumps);
|
||||
@@ -2642,6 +2648,8 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum)
|
||||
}
|
||||
|
||||
vlumps = static_cast<virtlump_t *>(Z_Malloc(sizeof(virtlump_t)*numlumps, PU_LEVEL, NULL));
|
||||
if (vlumps == NULL)
|
||||
I_Error("vres_GetMap: Out of memory!\n");
|
||||
|
||||
// Build the lumps, skipping over empty entries.
|
||||
for (i = 0, realentry = 0; i < numlumps; realentry++)
|
||||
@@ -2677,7 +2685,11 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum)
|
||||
lumpnum_t lumppos = lumpnum + 1;
|
||||
for (i = LUMPNUM(lumppos); i < wadfiles[WADFILENUM(lumpnum)]->numlumps; i++, lumppos++, numlumps++)
|
||||
{
|
||||
if (memcmp(W_CheckNameForNum(lumppos), "MAP", 3) == 0 || W_LumpLength(lumppos) == 0)
|
||||
const char *name = W_CheckNameForNum(lumppos);
|
||||
if (name == NULL)
|
||||
continue;
|
||||
|
||||
if (memcmp(name, "MAP", 3) == 0 || W_LumpLength(lumppos) == 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
@@ -2685,10 +2697,15 @@ virtres_t* vres_GetMap(lumpnum_t lumpnum)
|
||||
numlumps++;
|
||||
|
||||
vlumps = static_cast<virtlump_t *>(Z_Malloc(sizeof(virtlump_t)*numlumps, PU_LEVEL, NULL));
|
||||
if (vlumps == NULL)
|
||||
I_Error("vres_GetMap: Out of memory!\n");
|
||||
|
||||
for (i = 0; i < numlumps; i++, lumpnum++)
|
||||
{
|
||||
// Check if it is map marker. It is not always first lump sadly, so we need to expect it anywhere
|
||||
const char *name = W_CheckNameForNum(lumpnum);
|
||||
if (name == NULL)
|
||||
continue;
|
||||
|
||||
if (strlen(name) == 5 && memcmp(name, "MAP", 3) == 0)
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user