changeset 51110:0eeff620cdf5

8208466: Fix potential memory leak in harfbuzz shaping. Reviewed-by: jdv, kaddepalli
author prr
date Tue, 31 Jul 2018 12:23:55 -0700
parents 6ada313454e9
children 66d9993dd4ad
files src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ft.cc src/java.desktop/share/native/libfontmanager/harfbuzz/hb-ot-shape.cc
diffstat 2 files changed, 6 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- 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;