8010005: [parfait] Memory leak in jdk/src/macosx/native/sun/awt/CTextPipe.m
authorjgodinez
Wed, 27 Mar 2013 12:42:51 -0700
changeset 16702 fe534fb633cd
parent 16128 1ee796f45a7f
child 16703 5811e206dd2f
8010005: [parfait] Memory leak in jdk/src/macosx/native/sun/awt/CTextPipe.m Reviewed-by: bae, prr Contributed-by: jia-hong.chen@oracle.com
jdk/src/macosx/native/sun/awt/CTextPipe.m
--- a/jdk/src/macosx/native/sun/awt/CTextPipe.m	Thu Mar 14 19:26:02 2013 -0700
+++ b/jdk/src/macosx/native/sun/awt/CTextPipe.m	Wed Mar 27 12:42:51 2013 -0700
@@ -501,10 +501,22 @@
         int *uniChars = (int *)malloc(sizeof(int) * length);
         CGSize *advances = (CGSize *)malloc(sizeof(CGSize) * length);
 
-        if (glyphs == NULL || advances == NULL)
+        if (glyphs == NULL || uniChars == NULL || advances == NULL)
         {
             (*env)->DeleteLocalRef(env, glyphsArray);
             [NSException raise:NSMallocException format:@"%s-%s:%d", THIS_FILE, __FUNCTION__, __LINE__];
+            if (glyphs)
+            {
+                free(glyphs);
+            }
+            if (uniChars)
+            {
+                free(uniChars);
+            }
+            if (advances)
+            {
+                free(advances);
+            }
             return;
         }