[HarfBuzz] harfbuzz: Branch 'master'

Behdad Esfahbod behdad at kemper.freedesktop.org
Thu Jun 1 15:45:05 UTC 2017


 src/hb-common.cc |   14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

New commits:
commit 7dba30639a6f62803dfc21706bc7c654799f373e
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Jun 1 11:44:42 2017 -0400

    Handle allocation failure in hb-language code

diff --git a/src/hb-common.cc b/src/hb-common.cc
index daba0c55..4716cfb3 100644
--- a/src/hb-common.cc
+++ b/src/hb-common.cc
@@ -227,9 +227,12 @@ struct hb_language_item_t {
     */
     size_t len = strlen(s) + 1;
     lang = (hb_language_t) malloc(len);
-    memcpy((unsigned char *) lang, s, len);
-    for (unsigned char *p = (unsigned char *) lang; *p; p++)
-      *p = canon_map[*p];
+    if (likely (lang))
+    {
+      memcpy((unsigned char *) lang, s, len);
+      for (unsigned char *p = (unsigned char *) lang; *p; p++)
+	*p = canon_map[*p];
+    }
 
     return *this;
   }
@@ -271,6 +274,11 @@ retry:
     return NULL;
   lang->next = first_lang;
   *lang = key;
+  if (unlikely (!lang->lang))
+  {
+    free (lang);
+    return NULL;
+  }
 
   if (!hb_atomic_ptr_cmpexch (&langs, first_lang, lang)) {
     lang->finish ();


More information about the HarfBuzz mailing list