diff toys/pending/init.c @ 1481:c0c91437138b draft

A few fixes for issues reported in static analysis.
author Ashwini Sharma <ak.ashwini1981.gmail.com>
date Thu, 18 Sep 2014 11:47:42 -0500
parents c25ee9918e65
children
line wrap: on
line diff
--- a/toys/pending/init.c	Wed Sep 17 20:21:44 2014 -0500
+++ b/toys/pending/init.c	Thu Sep 18 11:47:42 2014 -0500
@@ -141,6 +141,8 @@
       line_number++;
       token_count = 0;
       action = 0;
+      tty_name = command = NULL;
+
       while ((extracted_token = strsep(&p,":"))) {
         token_count++;
         switch (token_count) {
@@ -172,8 +174,12 @@
       }  //while token
 
       if (q) free(q);
-      if (token_count != 4) continue; 
-      if (action) add_new_action(action, command, tty_name);  
+      if (token_count != 4) {
+        free(tty_name);
+        free(command);
+        continue;
+      }
+      if (action) add_new_action(action, command, tty_name);
       free(tty_name);
       free(command);
     } //while line