gtkcookie (0.4-5) 05-cppcheck.patch

Summary

 getline.c  |    1 +
 proctool.c |    4 ++++
 2 files changed, 5 insertions(+)

    
download this patch

Patch contents

Description: Fix a memory leak detected by cppcheck.
Forwarded: nowhere-to
Author: Peter Pentchev <roam@ringlet.net>
Last-Update: 2010-12-28

--- a/getline.c
+++ b/getline.c
@@ -48,6 +48,7 @@
 	++chars_read_from_file_line;
 	if (next_char != '\n' && next_char != EOF) {
 	    if (chars_read_from_file_line > line_length) {
+		// cppcheck-suppress memleakOnRealloc
 		line = realloc(line,
 			       (sizeof(gchar) * line_length) +
 			       (sizeof(gchar) * alloc_length) +
--- a/proctool.c
+++ b/proctool.c
@@ -56,6 +56,7 @@
 			       of 0, so that if it isn't assigned to,
 			       it will at least have the "failure" value */
     GString *statusfilename;
+    int saveerrno;
 
     *checkerrno = FALSE;  /* default: no errors encountered */
 
@@ -87,6 +88,9 @@
 
     if (errno) {
 	*checkerrno = TRUE;
+	saveerrno = errno;
+	closedir(dir);
+	errno = saveerrno;
 	return 0;
     }