OpenGL2: Add null dereference checks to DDS loader.

This commit is contained in:
SmileTheory 2015-12-18 19:42:15 -08:00
parent f965f3c66e
commit f78d04eba8

View file

@ -292,13 +292,18 @@ void R_LoadDDS ( const char *filename, byte **pic, int *width, int *height, GLen
len -= 4 + sizeof(*ddsHeader); len -= 4 + sizeof(*ddsHeader);
} }
*width = ddsHeader->width; if (width)
*height = ddsHeader->height; *width = ddsHeader->width;
if (height)
*height = ddsHeader->height;
if (ddsHeader->flags & _DDSFLAGS_MIPMAPCOUNT) if (numMips)
*numMips = ddsHeader->numMips; {
else if (ddsHeader->flags & _DDSFLAGS_MIPMAPCOUNT)
*numMips = 1; *numMips = ddsHeader->numMips;
else
*numMips = 1;
}
// FIXME: handle cube map // FIXME: handle cube map
//if ((ddsHeader->caps2 & DDSCAPS2_CUBEMAP) == DDSCAPS2_CUBEMAP) //if ((ddsHeader->caps2 & DDSCAPS2_CUBEMAP) == DDSCAPS2_CUBEMAP)