8211317: avoid memory leak in Java_sun_awt_UNIXToolkit_load_1stock_1icon
Reviewed-by: clanger, goetz
--- 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,