Fix leaks in fcxml.c, fc-match.c, and tests.
Fix leaks reported by AddressSanitizer when running 'make check'.
This commit is contained in:
parent
c00a51f4c8
commit
d55eaa6b31
|
@ -117,6 +117,7 @@ main (int argc, char **argv)
|
|||
int brief = 0;
|
||||
int sort = 0, all = 0;
|
||||
const FcChar8 *format = NULL;
|
||||
const FcChar8 *format_optarg = NULL;
|
||||
int i;
|
||||
FcObjectSet *os = 0;
|
||||
FcFontSet *fs;
|
||||
|
@ -146,7 +147,7 @@ main (int argc, char **argv)
|
|||
brief = 1;
|
||||
break;
|
||||
case 'f':
|
||||
format = (FcChar8 *) strdup (optarg);
|
||||
format = format_optarg = (FcChar8 *) strdup (optarg);
|
||||
break;
|
||||
case 'V':
|
||||
fprintf (stderr, "fontconfig version %d.%d.%d\n",
|
||||
|
@ -269,5 +270,10 @@ main (int argc, char **argv)
|
|||
|
||||
FcFini ();
|
||||
|
||||
if (format_optarg) {
|
||||
free ((void*)format_optarg);
|
||||
format_optarg = NULL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -2307,7 +2307,9 @@ FcParseCacheDir (FcConfigParse *parse)
|
|||
if (data[0] == 0)
|
||||
{
|
||||
FcConfigMessage (parse, FcSevereWarning, "empty cache directory name ignored");
|
||||
return;
|
||||
FcStrFree (data);
|
||||
data = prefix;
|
||||
goto bail;
|
||||
}
|
||||
if (prefix)
|
||||
{
|
||||
|
|
|
@ -221,6 +221,7 @@ main (void)
|
|||
ret = 1;
|
||||
goto bail;
|
||||
}
|
||||
FcFontSetDestroy (fs);
|
||||
fprintf (stderr, "D: Removing %s\n", fontdir);
|
||||
snprintf (cmd, 512, "sleep 1; rm -f %s%s*; sleep 1", fontdir, FC_DIR_SEPARATOR_S);
|
||||
(void) system (cmd);
|
||||
|
@ -243,6 +244,8 @@ main (void)
|
|||
ret = 3;
|
||||
goto bail;
|
||||
}
|
||||
FcConfigDestroy (config);
|
||||
|
||||
config = FcConfigCreate ();
|
||||
if (!FcConfigParseAndLoadFromMemory (config, (const FcChar8 *) conf, FcTrue))
|
||||
{
|
||||
|
@ -266,6 +269,7 @@ main (void)
|
|||
ret = 1;
|
||||
goto bail;
|
||||
}
|
||||
FcFontSetDestroy (fs);
|
||||
fprintf (stderr, "D: Copying %s to %s\n", FONTFILE, fontdir);
|
||||
snprintf (cmd, 512, "sleep 1; cp -a %s %s; sleep 1", FONTFILE, fontdir);
|
||||
(void) system (cmd);
|
||||
|
@ -288,6 +292,8 @@ main (void)
|
|||
ret = 3;
|
||||
goto bail;
|
||||
}
|
||||
FcConfigDestroy (config);
|
||||
|
||||
config = FcConfigCreate ();
|
||||
if (!FcConfigParseAndLoadFromMemory (config, (const FcChar8 *) conf, FcTrue))
|
||||
{
|
||||
|
@ -311,6 +317,8 @@ main (void)
|
|||
ret = 1;
|
||||
goto bail;
|
||||
}
|
||||
FcFontSetDestroy (fs);
|
||||
FcConfigDestroy (config);
|
||||
|
||||
bail:
|
||||
fprintf (stderr, "Cleaning up\n");
|
||||
|
|
|
@ -53,7 +53,9 @@ main (void)
|
|||
fprintf (stderr, "There was one or more cachedirs\n");
|
||||
return 1;
|
||||
}
|
||||
FcStrListDone (l);
|
||||
FcConfigDestroy (cfg);
|
||||
|
||||
cfg = FcConfigCreate ();
|
||||
if (!FcConfigParseAndLoadFromMemory (cfg, doc2, FcTrue))
|
||||
{
|
||||
|
@ -66,7 +68,7 @@ main (void)
|
|||
fprintf (stderr, "There was one or more cachedirs (with prefix)\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
FcStrListDone (l);
|
||||
FcConfigDestroy (cfg);
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue