[PATCH] binutils/windres.c: Fix memory leak issue for xmalloc and free 'n'

Chen Gang gang.chen.5i5j@gmail.com
Thu Nov 13 14:23:00 GMT 2014


After xmalloc 'n', if fopen() fails, need free 'n', or will cause memory
leak.

2014-11-13  Chen Gang  <gang.chen.5i5j@gmail.com>

	* binutiles/windres.c (open_file_search): Fix memory leak issue
	for xmalloc and free 'n'.
---
 binutils/windres.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/binutils/windres.c b/binutils/windres.c
index 7fa90fc..10aa722 100644
--- a/binutils/windres.c
+++ b/binutils/windres.c
@@ -204,6 +204,7 @@ open_file_search (const char *filename, const char *mode, const char *errmsg,
 	      *real_filename = n;
 	      return e;
 	    }
+	  free(n);
 
 	  if (errno != ENOENT)
 	    break;
-- 
1.9.3



More information about the Binutils mailing list