diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2014-04-21 18:12:59 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2014-04-21 18:12:59 -0600 |
commit | 47159ade11ffc2349f7d695b0d7838ab9d5fa7cf (patch) | |
tree | 40207f90b53572da4ccffd52e181cd3f8f19d836 /apps/nshlib/nsh_dbgcmds.c | |
parent | adef15b74515b624c5584458dcfaea6b7619ad2f (diff) | |
download | nuttx-47159ade11ffc2349f7d695b0d7838ab9d5fa7cf.tar.gz nuttx-47159ade11ffc2349f7d695b0d7838ab9d5fa7cf.tar.bz2 nuttx-47159ade11ffc2349f7d695b0d7838ab9d5fa7cf.zip |
NSH library: malloc/free IOBUFFER instead of using stack
Diffstat (limited to 'apps/nshlib/nsh_dbgcmds.c')
-rw-r--r-- | apps/nshlib/nsh_dbgcmds.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/apps/nshlib/nsh_dbgcmds.c b/apps/nshlib/nsh_dbgcmds.c index 15ce9498b..9f7ec205e 100644 --- a/apps/nshlib/nsh_dbgcmds.c +++ b/apps/nshlib/nsh_dbgcmds.c @@ -373,7 +373,7 @@ int cmd_xd(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) #ifndef CONFIG_NSH_DISABLE_HEXDUMP int cmd_hexdump(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) { - uint8_t buffer[IOBUFFERSIZE]; + FAR uint8_t *buffer; char msg[32]; off_t position; int fd; @@ -394,6 +394,13 @@ int cmd_hexdump(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) return ERROR; } + buffer = (FAR uint8_t *)malloc(IOBUFFERSIZE); + if(buffer == NULL) + { + nsh_output(vtbl, g_fmtcmdfailed, "hexdump", "malloc", NSH_ERRNO); + return ERROR; + } + #ifdef CONFIG_NSH_CMDOPT_HEXDUMP for (x = 2; x < argc; x++) { @@ -489,6 +496,7 @@ int cmd_hexdump(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) } (void)close(fd); + free(buffer); return ret; } #endif |