Free copy of input line at end of process_line instead of leaking it
authorAlan Coopersmith <alan.coopersmith@oracle.com>
Sat, 12 Nov 2011 04:46:00 +0000 (20:46 -0800)
committerAlan Coopersmith <alan.coopersmith@oracle.com>
Thu, 17 Nov 2011 06:58:43 +0000 (22:58 -0800)
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Jeremy Huddleston <jeremyhu@apple.com>
pf.c

diff --git a/pf.c b/pf.c
index 0cc8101..0eb0f55 100644 (file)
--- a/pf.c
+++ b/pf.c
@@ -30,6 +30,7 @@ from The Open Group.
 #include <X11/Xlib.h>
 #include <stdio.h>
 #include <ctype.h>
+#include <stdlib.h>
 #include "xmodmap.h"
 
 #define NOTINFILEFILENAME "commandline"
@@ -96,11 +97,11 @@ void process_line (const char *line)
        register char c = buffer[i];
        if (!(isspace(c) || c == '\n')) break;
     }
-    if (i == len) return;
+    if (i == len) goto done;
 
     cp = &buffer[i];
 
-    if (*cp == '!') return;            /* look for comments */
+    if (*cp == '!') goto done;         /* look for comments */
     len -= (cp - buffer);              /* adjust len by how much we skipped */
 
                                        /* pipe through cpp */
@@ -118,4 +119,7 @@ void process_line (const char *line)
 
     /* handle input */
     handle_line (cp, len);
+
+  done:
+    free(buffer);
 }