Package: mcpp / 2.7.2-5

02-gniibe-fixes.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
Description: Simple fixes
 * Fix freeing unmalloced memory
   The memory of 'in_file' is not malloced, but points to argv[].
   It is wrong to free it.
 * When there is no input file specified by argv, it causes error
   and fp_in == NULL.  Check is needed to call fclose for fp_in.
Author: NIIBE Yutaka

## Fixes the issue reported at:
## http://www.forallsecure.com/bug-reports/6b11b6fccda17cc467e055ccf7fec3fa2d89ec00/

Index: mcpp/src/main.c
===================================================================
--- mcpp.orig/src/main.c
+++ mcpp/src/main.c
@@ -428,16 +428,11 @@ int     main
 
 fatal_error_exit:
 #if MCPP_LIB
-    /* Free malloced memory */
-    if (mcpp_debug & MACRO_CALL) {
-        if (in_file != stdin_name)
-            free( in_file);
-    }
     clear_filelist();
     clear_symtable();
 #endif
 
-    if (fp_in != stdin)
+    if (fp_in && fp_in != stdin)
         fclose( fp_in);
     if (fp_out != stdout)
         fclose( fp_out);