8211317: avoid memory leak in Java_sun_awt_UNIXToolkit_load_1stock_1icon
authormbaesken
Mon, 01 Oct 2018 12:06:44 +0200
changeset 52251 b43c2aa001a5
parent 52250 cebf87487c33
child 52252 de9486d74a74
8211317: avoid memory leak in Java_sun_awt_UNIXToolkit_load_1stock_1icon Reviewed-by: clanger, goetz
src/java.desktop/unix/native/libawt_xawt/awt/awt_UNIXToolkit.c
--- a/src/java.desktop/unix/native/libawt_xawt/awt/awt_UNIXToolkit.c	Tue Oct 09 12:08:59 2018 +0530
+++ b/src/java.desktop/unix/native/libawt_xawt/awt/awt_UNIXToolkit.c	Mon Oct 01 12:06:44 2018 +0200
@@ -183,6 +183,7 @@
         detail_str = (char *)SAFE_SIZE_ARRAY_ALLOC(malloc,
                 sizeof(char), len + 1);
         if (detail_str == NULL) {
+            free(stock_id_str);
             JNU_ThrowOutOfMemoryError(env, "OutOfMemoryError");
             return JNI_FALSE;
         }
@@ -190,6 +191,10 @@
     }
 
     if (!init_method(env, this) ) {
+        free(stock_id_str);
+        if (detail_str != NULL) {
+            free(detail_str);
+        }
         return JNI_FALSE;
     }
     jboolean result = gtk->get_icon_data(env, widget_type, stock_id_str,