mirror of
https://github.com/TerryCavanagh/VVVVVV.git
synced 2026-01-29 09:28:15 +03: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:
@@ -1103,7 +1103,7 @@ void Graphics::updatetextboxes(void)
|
|||||||
|
|
||||||
void Graphics::drawimagecol( int t, int xp, int yp, bool cent/*= false*/ )
|
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;
|
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*/ )
|
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;
|
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)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user