diff options
author | SmileTheory <SmileTheory@gmail.com> | 2015-12-18 19:42:15 -0800 |
---|---|---|
committer | Tim Angus <tim@ngus.net> | 2016-04-07 11:46:04 +0100 |
commit | ab9a49f87ddd323ce1958d0834ddbb7cab199f12 (patch) | |
tree | c534f00208116ad5b4fa51f4a25593358654ecf7 /src/renderergl2/tr_image_dds.c | |
parent | 342a3bd68085cdc11f3167253492043459ee9910 (diff) |
OpenGL2: Add null dereference checks to DDS loader.
Diffstat (limited to 'src/renderergl2/tr_image_dds.c')
-rw-r--r-- | src/renderergl2/tr_image_dds.c | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/renderergl2/tr_image_dds.c b/src/renderergl2/tr_image_dds.c index 578b3eda..8ad406fd 100644 --- a/src/renderergl2/tr_image_dds.c +++ b/src/renderergl2/tr_image_dds.c @@ -292,13 +292,18 @@ void R_LoadDDS ( const char *filename, byte **pic, int *width, int *height, GLen len -= 4 + sizeof(*ddsHeader); } - *width = ddsHeader->width; - *height = ddsHeader->height; + if (width) + *width = ddsHeader->width; + if (height) + *height = ddsHeader->height; - if (ddsHeader->flags & _DDSFLAGS_MIPMAPCOUNT) - *numMips = ddsHeader->numMips; - else - *numMips = 1; + if (numMips) + { + if (ddsHeader->flags & _DDSFLAGS_MIPMAPCOUNT) + *numMips = ddsHeader->numMips; + else + *numMips = 1; + } // FIXME: handle cube map //if ((ddsHeader->caps2 & DDSCAPS2_CUBEMAP) == DDSCAPS2_CUBEMAP) |