8073699: Memory leak in jdk/src/java/desktop/share/native/libjavajpeg/imageioJPEG.c
authorprr
Wed, 25 Feb 2015 13:45:09 -0800
changeset 29506 a7367abd4c4c
parent 29505 682be03b8f41
child 29507 f16389ada5f3
8073699: Memory leak in jdk/src/java/desktop/share/native/libjavajpeg/imageioJPEG.c Reviewed-by: bae, serb
jdk/src/java.desktop/share/native/libjavajpeg/imageioJPEG.c
--- a/jdk/src/java.desktop/share/native/libjavajpeg/imageioJPEG.c	Wed Feb 25 14:01:27 2015 +0300
+++ b/jdk/src/java.desktop/share/native/libjavajpeg/imageioJPEG.c	Wed Feb 25 13:45:09 2015 -0800
@@ -2778,6 +2778,14 @@
     pb = &data->pixelBuf;
 
     if (setPixelBuffer(env, pb, buffer) == NOT_OK) {
+        if (scale != NULL) {
+            for (i = 0; i < numBands; i++) {
+                if (scale[i] != NULL) {
+                    free(scale[i]);
+                }
+            }
+            free(scale);
+        }
         return data->abortFlag;  // We already threw an out of memory exception
     }