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:
parent
ed2ccad735
commit
321924c0a5
@ -1417,4 +1417,6 @@
|
|||||||
initialized the network (2015-08-26).
|
initialized the network (2015-08-26).
|
||||||
* apps/nettest: Extend test so that can be performed using the local
|
* apps/nettest: Extend test so that can be performed using the local
|
||||||
loopback device (2015-08-26).
|
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).
|
||||||
|
@ -439,6 +439,7 @@ static int cat_common(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd,
|
|||||||
buffer = (FAR char *)malloc(IOBUFFERSIZE);
|
buffer = (FAR char *)malloc(IOBUFFERSIZE);
|
||||||
if(buffer == NULL)
|
if(buffer == NULL)
|
||||||
{
|
{
|
||||||
|
(void)close(fd);
|
||||||
nsh_output(vtbl, g_fmtcmdfailed, cmd, "malloc", NSH_ERRNO);
|
nsh_output(vtbl, g_fmtcmdfailed, cmd, "malloc", NSH_ERRNO);
|
||||||
return ERROR;
|
return ERROR;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user