From 6c3c2603b9f68a7460e9642d0421b5cc5a848452 Mon Sep 17 00:00:00 2001 From: Akira TAGOH Date: Wed, 18 Jun 2014 11:49:10 +0900 Subject: [PATCH] Fix a segfault introduced by the previous commit d17f556153fbaf8fe57fdb4fc1f0efa4313f0ecf --- src/fcdir.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/fcdir.c b/src/fcdir.c index b35997f..593382f 100644 --- a/src/fcdir.c +++ b/src/fcdir.c @@ -153,19 +153,21 @@ FcFileScanConfig (FcFontSet *set, if (FcFileIsDir (file)) { const FcChar8 *sysroot = FcConfigGetSysRoot (config); - const FcChar8 *d; - size_t len = strlen ((const char *)sysroot); + const FcChar8 *d = file; + size_t len; - if (sysroot && strncmp ((const char *)file, (const char *)sysroot, len) == 0) + if (sysroot) { - if (file[len] != '/') - len--; - else if (file[len+1] == '/') - len++; - d = &file[len]; + len = strlen ((const char *)sysroot); + if (strncmp ((const char *)file, (const char *)sysroot, len) == 0) + { + if (file[len] != '/') + len--; + else if (file[len+1] == '/') + len++; + d = &file[len]; + } } - else - d = file; return FcStrSetAdd (dirs, d); } else