apps/nshlib: Fix error handling in 'mv' command. On a failure to expand the second path, the memory allocated for the expansion of the first path was not being freed. From Bruno Herrera.

This commit is contained in:
Bruno Herrera 2015-08-30 18:28:04 -06:00 committed by Gregory Nutt
parent 321924c0a5
commit 4555282571
2 changed files with 7 additions and 4 deletions

View File

@ -1418,5 +1418,8 @@
* apps/nettest: Extend test so that can be performed using the local
loopback device (2015-08-26).
* apps/nshlib: Fix error handling in 'cat' command. On a failure to
allocate memory, a file ws not being closed. From Bruno Herrera
allocate memory, a file was not being closed. From Bruno Herrera
(2015-08-26).
* apps/nshlib: Fix error handling in 'mv' command. On a failure to
expand the second path, the memory allocated for the expansion of the
first path was not being freed. From Bruno Herrera (2015-08-26).

View File

@ -1348,8 +1348,8 @@ int cmd_mv(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
newpath = nsh_getfullpath(vtbl, argv[2]);
if (!newpath)
{
nsh_freefullpath(newpath);
return ERROR;
ret = ERROR;
goto errout_with_free;
}
/* Perform the mount */
@ -1361,7 +1361,7 @@ int cmd_mv(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv)
}
/* Free the file paths */
errout_with_free:
nsh_freefullpath(oldpath);
nsh_freefullpath(newpath);
return ret;