1
0
Fork 0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-12-22 17:49:43 +01:00

Fix potential NULL dereference of images[t]

Without this, entering in-game and opening the map with missing graphics
will result in a segfault. This is because even if the image doesn't
exist, it's still pushed into the `images` std::vector as a NULL
pointer. And it segfaults because we dereference it (to get things like
their width and height). In contrast, passing them to SDL is fine
because SDL always checks for NULL first.
This commit is contained in:
Misa 2022-05-17 12:07:51 -07:00
parent a23a4cbbd0
commit e77fad5db8

View file

@ -1103,7 +1103,7 @@ void Graphics::updatetextboxes(void)
void Graphics::drawimagecol( int t, int xp, int yp, bool cent/*= false*/ )
{
if (!INBOUNDS_VEC(t, images))
if (!INBOUNDS_VEC(t, images) || images[t] == NULL)
{
return;
}
@ -1134,7 +1134,7 @@ void Graphics::drawimagecol( int t, int xp, int yp, bool cent/*= false*/ )
void Graphics::drawimage( int t, int xp, int yp, bool cent/*=false*/ )
{
if (!INBOUNDS_VEC(t, images))
if (!INBOUNDS_VEC(t, images) || images[t] == NULL)
{
return;
}
@ -1162,7 +1162,7 @@ void Graphics::drawimage( int t, int xp, int yp, bool cent/*=false*/ )
void Graphics::drawpartimage( int t, int xp, int yp, int wp, int hp)
{
if (!INBOUNDS_VEC(t, images))
if (!INBOUNDS_VEC(t, images) || images[t] == NULL)
{
return;
}