- don't leak resources, CID 609+610 run 2
authorKamil Hornicek <kamil.hornicek@reactos.org>
Fri, 21 Nov 2008 10:31:18 +0000 (10:31 +0000)
committerKamil Hornicek <kamil.hornicek@reactos.org>
Fri, 21 Nov 2008 10:31:18 +0000 (10:31 +0000)
svn path=/trunk/; revision=37506

reactos/dll/win32/glu32/libutil/mipmap.c

index 8eaac3c..b943c7b 100644 (file)
@@ -3483,10 +3483,15 @@ gluScaleImage(GLenum format, GLsizei widthin, GLsizei heightin,
     }
     beforeImage =
        malloc(image_size(widthin, heightin, format, GL_UNSIGNED_SHORT));
+    if (beforeImage == NULL) {
+               return GLU_OUT_OF_MEMORY;
+    }
+
     afterImage =
        malloc(image_size(widthout, heightout, format, GL_UNSIGNED_SHORT));
-    if (beforeImage == NULL || afterImage == NULL) {
-       return GLU_OUT_OF_MEMORY;
+    if (afterImage == NULL) {
+               free(beforeImage);
+               return GLU_OUT_OF_MEMORY;
     }
 
     retrieveStoreModes(&psm);
@@ -7339,9 +7344,14 @@ int gluScaleImage3D(GLenum format,
 
    beforeImage = malloc(imageSize3D(widthIn, heightIn, depthIn, format,
                                    GL_UNSIGNED_SHORT));
+   if (beforeImage == NULL) {
+       return GLU_OUT_OF_MEMORY;
+   }
+
    afterImage = malloc(imageSize3D(widthOut, heightOut, depthOut, format,
                                   GL_UNSIGNED_SHORT));
-   if (beforeImage == NULL || afterImage == NULL) {
+   if (afterImage == NULL) {
+       free(beforeImage);
        return GLU_OUT_OF_MEMORY;
    }
    retrieveStoreModes3D(&psm);