]> git.wh0rd.org - fontconfig.git/blobdiff - src/fcstr.c
Avoid crash when $HOME is not set
[fontconfig.git] / src / fcstr.c
index efb82e1358ad957586fe391bb9df89f76ca0d903..3a31b22584b976b4ef775c033eee4b3ed11487fe 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $XFree86: xc/lib/fontconfig/src/fcstr.c,v 1.7 2002/07/13 05:43:25 keithp Exp $
+ * $XFree86: xc/lib/fontconfig/src/fcstr.c,v 1.10 2002/08/31 22:17:32 keithp Exp $
  *
  * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc.
  *
@@ -283,7 +283,7 @@ FcUtf16ToUcs4 (const FcChar8        *src_orig,
        if ((b & 0xfc00) != 0xdc00)
            return 0;
        result = ((((FcChar32) a & 0x3ff) << 10) |
-                 ((FcChar32) b & 0x3ff)) | 0x10000;
+                 ((FcChar32) b & 0x3ff)) + 0x10000;
     }
     else
        result = a;
@@ -428,9 +428,10 @@ FcStrCopyFilename (const FcChar8 *s)
     if (*s == '~')
     {
        FcChar8 *home = (FcChar8 *) getenv ("HOME");
-       int     size = strlen ((char *) home) + strlen ((char *) s);
+       int     size;
        if (!home)
            return 0;
+       size = strlen ((char *) home) + strlen ((char *) s);
        new = (FcChar8 *) malloc (size);
        if (!new)
            return 0;