Avoid memory leak when NULL path passed to FcStrBuildFilename

Reported by parfait 1.3:
   Memory leak of pointer sset allocated with FcStrSetCreate()
        at line 933 of src/fcstr.c in function 'FcStrBuildFilename'.
          sset allocated at line 927 with FcStrSetCreate().
          sset leaks when sset != NULL at line 932.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
This commit is contained in:
Alan Coopersmith 2013-11-02 10:23:56 -07:00 committed by Akira TAGOH
parent cb72901d0b
commit 5b8380d52e
1 changed files with 6 additions and 2 deletions

View File

@ -924,12 +924,16 @@ FcStrBuildFilename (const FcChar8 *path,
...)
{
va_list ap;
FcStrSet *sset = FcStrSetCreate ();
FcStrSet *sset;
FcStrList *list;
FcChar8 *s, *ret = NULL, *p;
size_t len = 0;
if (!sset || !path)
if (!path)
return NULL;
sset = FcStrSetCreate ();
if (!sset)
return NULL;
if (!FcStrSetAdd (sset, path))