8208466: Fix potential memory leak in harfbuzz shaping.
Reviewed-by: jdv, kaddepalli
--- 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;