From: Kahrl Date: Sat, 6 Jul 2013 04:16:51 +0000 (+0200) Subject: Fix possible NULL dereference in createExtrudedMesh X-Git-Tag: 0.4.8~350 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=3607fae75a00a1d0fee1b5caf58d04dcd9e2bc3a;p=oweals%2Fminetest.git Fix possible NULL dereference in createExtrudedMesh --- 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