aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKahrl <kahrl@gmx.net>2013-07-06 06:16:51 +0200
committerKahrl <kahrl@gmx.net>2013-07-06 06:16:51 +0200
commit3607fae75a00a1d0fee1b5caf58d04dcd9e2bc3a (patch)
tree6ebb70387a30a9568b12276706be1ce6a74c879a /src
parent922a30ee47edbd6255cd6cbea0f89f21c607094c (diff)
downloadminetest-3607fae75a00a1d0fee1b5caf58d04dcd9e2bc3a.tar.gz
minetest-3607fae75a00a1d0fee1b5caf58d04dcd9e2bc3a.tar.bz2
minetest-3607fae75a00a1d0fee1b5caf58d04dcd9e2bc3a.zip
Fix possible NULL dereference in createExtrudedMesh
Diffstat (limited to 'src')
-rw-r--r--src/mesh.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/mesh.cpp b/src/mesh.cpp
index a98cb8bf4..14a194b88 100644
--- a/src/mesh.cpp
+++ b/src/mesh.cpp
@@ -280,15 +280,17 @@ scene::IAnimatedMesh* createExtrudedMesh(video::ITexture *texture,
// img1 is in the texture's color format, convert to 8-bit ARGB
video::IImage *img2 = driver->createImage(video::ECF_A8R8G8B8, size);
- if (img2 != NULL)
+ if (img2 == NULL)
{
- img1->copyTo(img2);
-
- mesh = extrudeARGB(size.Width, size.Height, (u8*) img2->lock());
- img2->unlock();
- img2->drop();
+ img1->drop();
+ return NULL;
}
+
+ img1->copyTo(img2);
img1->drop();
+ mesh = extrudeARGB(size.Width, size.Height, (u8*) img2->lock());
+ img2->unlock();
+ img2->drop();
}
// Set default material