[PATCH 2/3] Avoid memory leak when NULL path passed to FcStrBuildFilename

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 src/fcstr.c |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/fcstr.c b/src/fcstr.c
index 5707172..024dae3 100644
--- a/src/fcstr.c
+++ b/src/fcstr.c
@@ -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))
-- 
1.7.9.2

_______________________________________________
Fontconfig mailing list
Fontconfig@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/fontconfig




[Index of Archives]     [Fedora Fonts]     [Fedora Users]     [Fedora Cloud]     [Kernel]     [Fedora Packaging]     [Fedora Desktop]     [PAM]     [Gimp Graphics Editor]     [Yosemite News]

  Powered by Linux