do not dereference NULL upon failed strdup
authorJim Meyering <meyering@redhat.com>
Sat, 2 Apr 2011 13:52:34 +0000 (15:52 +0200)
committerJim Meyering <meyering@redhat.com>
Sat, 2 Apr 2011 13:52:34 +0000 (15:52 +0200)
* nsfont.m (ns_descriptor_to_entity): Use xstrdup, not strdup.
(ns_get_family): Likewise.

src/ChangeLog
src/nsfont.m

index f659563..e96968c 100644 (file)
@@ -1,3 +1,9 @@
+2011-04-02  Jim Meyering  <meyering@redhat.com>
+
+       do not dereference NULL upon failed strdup
+       * nsfont.m (ns_descriptor_to_entity): Use xstrdup, not strdup.
+       (ns_get_family): Likewise.
+
 2011-04-02  Juanma Barranquero  <lekktu@gmail.com>
 
        * eval.c (unwind_to_catch) [DEBUG_GCPRO]: Remove redundant assignment.
index 68cd19d..48d4022 100644 (file)
@@ -100,7 +100,7 @@ ns_get_family (Lisp_Object font_spec)
       return nil;
   else
     {
-      char *tmp = strdup (SDATA (SYMBOL_NAME (tem)));
+      char *tmp = xstrdup (SDATA (SYMBOL_NAME (tem)));
       NSString *family;
       ns_unescape_name (tmp);
       family = [NSString stringWithUTF8String: tmp];
@@ -176,7 +176,7 @@ ns_descriptor_to_entity (NSFontDescriptor *desc,
     if (family == nil)
       family = [[NSFont userFixedPitchFontOfSize: 0] familyName];
 
-    escapedFamily = strdup ([family UTF8String]);
+    escapedFamily = xstrdup ([family UTF8String]);
     ns_escape_name (escapedFamily);
 
     ASET (font_entity, FONT_TYPE_INDEX, Qns);
@@ -1526,4 +1526,3 @@ syms_of_nsfont (void)
   DEFVAR_LISP ("ns-reg-to-script", Vns_reg_to_script,
                doc: /* Internal use: maps font registry to unicode script. */);
 }
-