8146317: Memory leak in wcstombsdmp
authorserb
Mon, 18 Jan 2016 21:19:36 +0300
changeset 35677 c243e74116f8
parent 35676 6833f789a32d
child 35678 ad6cfe2f2e13
8146317: Memory leak in wcstombsdmp Reviewed-by: serb, psadhukhan, ssadetsky Contributed-by: Alex Henrie <alexhenrie24@gmail.com>
jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_InputMethod.c
--- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_InputMethod.c	Mon Jan 18 14:37:25 2016 +0530
+++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_InputMethod.c	Mon Jan 18 21:19:36 2016 +0300
@@ -221,8 +221,10 @@
     }
 
     /* TODO: check return values... Handle invalid characters properly...  */
-    if (wcstombs(mbs, wcs, n) == (size_t)-1)
+    if (wcstombs(mbs, wcs, n) == (size_t)-1) {
+        free(mbs);
         return NULL;
+    }
 
     return mbs;
 }