OSDN Git Service

gatttool: Fix memory leak after parsing input line
authorJefferson Delfes <jefferson.delfes@openbossa.org>
Tue, 2 Apr 2013 23:31:18 +0000 (19:31 -0400)
committerJohan Hedberg <johan.hedberg@intel.com>
Sun, 7 Apr 2013 15:09:58 +0000 (18:09 +0300)
The callback is responsible for freeing input line buffer that comes
from rl_callback_handler_install().

attrib/interactive.c

index a99ad0a..9f72453 100644 (file)
@@ -850,7 +850,7 @@ static void parse_line(char *line_read)
        line_read = g_strstrip(line_read);
 
        if (*line_read == '\0')
-               return;
+               goto done;
 
        add_history(line_read);
 
@@ -866,6 +866,9 @@ static void parse_line(char *line_read)
                printf("%s: command not found\n", argvp[0]);
 
        g_strfreev(argvp);
+
+done:
+       free(line_read);
 }
 
 static gboolean prompt_read(GIOChannel *chan, GIOCondition cond,