changeset 52272:b43c2aa001a5

8211317: avoid memory leak in Java_sun_awt_UNIXToolkit_load_1stock_1icon Reviewed-by: clanger, goetz
author mbaesken
date Mon, 01 Oct 2018 12:06:44 +0200
parents cebf87487c33
children de9486d74a74
files src/java.desktop/unix/native/libawt_xawt/awt/awt_UNIXToolkit.c
diffstat 1 files changed, 5 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- 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,