Parcourir la source

Merge pull request #3679 from DavidLin1577/patch-11

[finsh]Fixed a bug may cause stackover flow
Bernard Xiong il y a 5 ans
Parent
commit
b04fdd89ed
1 fichiers modifiés avec 5 ajouts et 0 suppressions
  1. 5 0
      components/finsh/msh_file.c

+ 5 - 0
components/finsh/msh_file.c

@@ -101,6 +101,11 @@ int msh_exec_script(const char *cmd_line, int size)
         int length;
 
         line_buf = (char *) rt_malloc(RT_CONSOLEBUF_SIZE);
+        if (line_buf == RT_NULL) 
+        {
+            close(fd);
+            return -RT_ENOMEM;
+        }
 
         /* read line by line and then exec it */
         do