diff options
author | Michael J. Chudobiak <mjc@avtechpulse.com> | 2012-08-14 10:43:20 -0400 |
---|---|---|
committer | Michael J. Chudobiak <mjc@avtechpulse.com> | 2012-08-14 10:43:20 -0400 |
commit | fed09a34189c3e2f3e8378f143c63683767d0104 (patch) | |
tree | 2108cb343321758da504cbba033fc99e67e33436 /parser.c | |
parent | ad41125d65400ae608d99fd95aefad93102d260e (diff) |
Fix improper string memory allocation
Diffstat (limited to 'parser.c')
-rw-r--r-- | parser.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -527,7 +527,7 @@ static int Parser_get_unit(char *parameter,char *units) return units_present;
}
-void Parser_main (char *in, int interactive_terminal, void(*cbfunc)(gpointer, gchar *), gpointer user_data)
+void Parser_main (char *raw_in, int interactive_terminal, void(*cbfunc)(gpointer, gchar *), gpointer user_data)
{
int in_pos; /* this identifies the single character of in being processed */
int command_depth; /* how many command words have been parsed */
@@ -556,7 +556,10 @@ void Parser_main (char *in, int interactive_terminal, void(*cbfunc)(gpointer, gc int channel;
int with_id_code;
- strcpy(in+strlen(in)," "); /* add white space to the end of the input string */
+ g_strstrip (raw_in);
+
+ // add white space to the end of the input string - FIXME?
+ gchar *in = g_strdup_printf ("%s ", raw_in);
in_pos = 0; /* start at the beginning of the input string */
semicolon_found = 0;
@@ -768,8 +771,11 @@ void Parser_main (char *in, int interactive_terminal, void(*cbfunc)(gpointer, gc if (interactive_terminal) {
(*cbfunc)(user_data, "");
}
+
+ g_free (in);
}
+
static int Parser_channel (int *channel,int with_id_code,int routine_num)
{
/* return if no channel suffixes appeared */
|