]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
sim: Be sure of calling freeargv() after successfully call buildargv().
authorChen Gang <gang.chen.5i5j@gmail.com>
Fri, 30 Jan 2015 22:06:38 +0000 (06:06 +0800)
committerChen Gang <gang.chen.5i5j@gmail.com>
Mon, 2 Feb 2015 20:03:38 +0000 (04:03 +0800)
Or there will be memory leak.

2015-02-02  Chen Gang <gang.chen.5i5j@gmail.com>

* mcore/interp.c (sim_do_command): Call freeargv() before return.

sim/ChangeLog
sim/mcore/interp.c

index 9ddee6482df2317480f1c42cc8ebc0baa9258273..628e6a8b09f647ff09d3de20258ae3a25e2b3b97 100644 (file)
@@ -1,3 +1,7 @@
+2015-02-02  Chen Gang <gang.chen.5i5j@gmail.com>
+
+       * mcore/interp.c (sim_do_command): Call freeargv() before return.
+
 2015-02-02  Chen Gang <gang.chen.5i5j@gmail.com>
 
        * common/sim-options.c (sim_args_command): Call freeargv() when
index d2edd126c3f44ae8c4203b058b406452cf31ec75..dfaa6aacbd0450aea3a397fae6a038210f1bcb8f 100644 (file)
@@ -2143,6 +2143,7 @@ sim_do_command (sd, cmd)
          if ((simargv[1] == NULL) || (simargv[2] == NULL))
            {
              fprintf (stderr, "Error: missing argument to watch cmd.\n");
+             freeargv (simargv);
              return;
            }
          
@@ -2187,6 +2188,8 @@ sim_do_command (sd, cmd)
          fprintf (stderr,"Error: \"%s\" is not a valid M.CORE simulator command.\n",
                   cmd);
        }
+
+      freeargv (simargv);
     }
   else
     {