Allow get_table() to return NULL
authorBehdad Esfahbod <behdad@behdad.org>
Fri, 23 Apr 2010 23:59:53 +0000 (19:59 -0400)
committerBehdad Esfahbod <behdad@behdad.org>
Fri, 23 Apr 2010 23:59:53 +0000 (19:59 -0400)
src/hb-font.cc
src/hb-ft.c

index 4fdb569..f913f7e 100644 (file)
@@ -324,10 +324,14 @@ hb_blob_t *
 hb_face_get_table (hb_face_t *face,
                   hb_tag_t   tag)
 {
+  hb_blob_t *blob;
+
   if (HB_UNLIKELY (!face || !face->get_table))
     return hb_blob_create_empty ();
 
-  return face->get_table (tag, face->user_data);
+  blob = face->get_table (tag, face->user_data);
+
+  return blob? blob : hb_blob_create_empty ();
 }
 
 
index b5dd657..3e91eff 100644 (file)
@@ -159,7 +159,7 @@ _get_table  (hb_tag_t tag, void *user_data)
   /* TODO Use FT_Memory? */
   buffer = malloc (length);
   if (buffer == NULL)
-    return hb_blob_create_empty ();
+    return NULL;
 
   error = FT_Load_Sfnt_Table (ft_face, tag, 0, buffer, &length);
   if (error)