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