Fix a segfault

introduced by the previous commit d17f556153
This commit is contained in:
Akira TAGOH 2014-06-18 11:49:10 +09:00
parent 8915c15b9e
commit 6c3c2603b9
1 changed files with 12 additions and 10 deletions

View File

@ -153,19 +153,21 @@ FcFileScanConfig (FcFontSet *set,
if (FcFileIsDir (file)) if (FcFileIsDir (file))
{ {
const FcChar8 *sysroot = FcConfigGetSysRoot (config); const FcChar8 *sysroot = FcConfigGetSysRoot (config);
const FcChar8 *d; const FcChar8 *d = file;
size_t len = strlen ((const char *)sysroot); size_t len;
if (sysroot && strncmp ((const char *)file, (const char *)sysroot, len) == 0) if (sysroot)
{ {
if (file[len] != '/') len = strlen ((const char *)sysroot);
len--; if (strncmp ((const char *)file, (const char *)sysroot, len) == 0)
else if (file[len+1] == '/') {
len++; if (file[len] != '/')
d = &file[len]; len--;
else if (file[len+1] == '/')
len++;
d = &file[len];
}
} }
else
d = file;
return FcStrSetAdd (dirs, d); return FcStrSetAdd (dirs, d);
} }
else else