apps/nshlib: Fix error handling in 'cat' command. On a failure to allocate memory, a file was not being closed. From Bruno Herrera.

This commit is contained in:
Bruno Herrera 2015-08-30 18:23:25 -06:00 committed by Gregory Nutt
parent ed2ccad735
commit 321924c0a5
2 changed files with 4 additions and 1 deletions

View File

@ -1417,4 +1417,6 @@
initialized the network (2015-08-26).
* 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
(2015-08-26).

View File

@ -439,6 +439,7 @@ static int cat_common(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
buffer = (FAR char *)malloc(IOBUFFERSIZE);
if(buffer == NULL)
{
(void)close(fd);
nsh_output(vtbl, g_fmtcmdfailed, cmd, "malloc", NSH_ERRNO);
return ERROR;
}