8208466: Fix potential memory leak in harfbuzz shaping.
authorprr
Tue, 31 Jul 2018 12:23:55 -0700
changeset 51303 0eeff620cdf5
parent 51302 6ada313454e9
child 51304 66d9993dd4ad
8208466: Fix potential memory leak in harfbuzz shaping. Reviewed-by: jdv, kaddepalli
src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ft.cc
src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape.cc
--- a/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ft.cc	Tue Jul 31 21:23:56 2018 +0300
+++ b/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ft.cc	Tue Jul 31 12:23:55 2018 -0700
@@ -497,8 +497,10 @@
     return nullptr;
 
   error = FT_Load_Sfnt_Table (ft_face, tag, 0, buffer, &length);
-  if (error)
+  if (error) {
+    free (buffer);
     return nullptr;
+  }
 
   return hb_blob_create ((const char *) buffer, length,
                          HB_MEMORY_MODE_WRITABLE,
--- a/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape.cc	Tue Jul 31 21:23:56 2018 +0300
+++ b/src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape.cc	Tue Jul 31 12:23:55 2018 -0700
@@ -193,8 +193,10 @@
 
   if (plan->shaper->data_create) {
     plan->data = plan->shaper->data_create (plan);
-    if (unlikely (!plan->data))
+    if (unlikely (!plan->data)) {
+      free(plan);
       return nullptr;
+    }
   }
 
   return plan;