[OpenJDK 2D-Dev] RFR: Backport :8073699: Memory leak in jdk/src/java/desktop/share/native/libjavajpeg/imageioJPEG.c

Phil Race philip.race at oracle.com
Mon Apr 20 18:49:42 UTC 2015


Andrew & Sergey,

Please review this identical 8u60 backport (diff below) of the JDK 9 fix 
: http://hg.openjdk.java.net/jdk9/hs/jdk/rev/b7e402c9b183

hg diff imageioJPEG.c
diff --git a/src/share/native/sun/awt/image/jpeg/imageioJPEG.c 
b/src/share/native/sun/awt/image/jpeg/imageioJPEG.c
--- a/src/share/native/sun/awt/image/jpeg/imageioJPEG.c
+++ b/src/share/native/sun/awt/image/jpeg/imageioJPEG.c
@@ -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
      }

-phil.



More information about the 2d-dev mailing list