[PATCH:libX11 01/12] Fix file leak on malloc error in XlcDL.c:resolve_object()

Alan Coopersmith alan.coopersmith at oracle.com
Sat Aug 10 13:54:58 PDT 2013


File Leak: Leaked File fp
   at line 219 of lib/libX11/src/xlibi18n/XlcDL.c in function 'resolve_object'.
      fp initialized at line 198 with fopen

[ This bug was found by the Parfait 1.2.0 bug checking tool.
  For more information see http://labs.oracle.com/projects/parfait/ ]

Signed-off-by: Alan Coopersmith <alan.coopersmith at oracle.com>
---
 src/xlibi18n/XlcDL.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/xlibi18n/XlcDL.c b/src/xlibi18n/XlcDL.c
index 75e193c..79e8a2f 100644
--- a/src/xlibi18n/XlcDL.c
+++ b/src/xlibi18n/XlcDL.c
@@ -216,7 +216,8 @@ Limit the length of path to prevent stack buffer corruption.
 	  xi18n_objects_list = (XI18NObjectsList)
 	    Xrealloc(xi18n_objects_list,
 		     sizeof(XI18NObjectsListRec) * lc_len);
-	  if (!xi18n_objects_list) return;
+	  if (!xi18n_objects_list)
+	      goto done;
 	}
 	n = parse_line(p, args, 6);
 
@@ -244,6 +245,7 @@ Limit the length of path to prevent stack buffer corruption.
 	  lc_count++;
 	}
     }
+  done:
     fclose(fp);
 }
 
-- 
1.7.9.2



More information about the xorg-devel mailing list