This is an automated email from Gerrit. Spencer Oliver ([email protected]) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/776
-- gerrit commit 6a424f07dd9042189803603309dd5adeb0260aa4 Author: Spencer Oliver <[email protected]> Date: Mon Aug 13 11:31:54 2012 +0100 tcl: fix potential memory leaks Reorder to allocate all memory after COMMAND_PARSE_NUMBER call. This removes a clang warning about un-released memory Change-Id: I8dbeb664a6467077157015bd879bc0aefc5e8614 Signed-off-by: Spencer Oliver <[email protected]> diff --git a/src/flash/nor/tcl.c b/src/flash/nor/tcl.c index ec80f6f..cf6fa08 100644 --- a/src/flash/nor/tcl.c +++ b/src/flash/nor/tcl.c @@ -427,16 +427,7 @@ COMMAND_HANDLER(handle_flash_fill_command) int retval = ERROR_OK; static size_t const chunksize = 1024; - uint8_t *chunk = malloc(chunksize); - if (chunk == NULL) - return ERROR_FAIL; - - uint8_t *readback = malloc(chunksize); - if (readback == NULL) { - free(chunk); - return ERROR_FAIL; - } - + uint8_t *chunk = NULL, *readback = NULL; if (CMD_ARGC != 3) { retval = ERROR_COMMAND_SYNTAX_ERROR; @@ -447,6 +438,16 @@ COMMAND_HANDLER(handle_flash_fill_command) COMMAND_PARSE_NUMBER(u32, CMD_ARGV[1], pattern); COMMAND_PARSE_NUMBER(u32, CMD_ARGV[2], count); + chunk = malloc(chunksize); + if (chunk == NULL) + return ERROR_FAIL; + + readback = malloc(chunksize); + if (readback == NULL) { + free(chunk); + return ERROR_FAIL; + } + if (count == 0) goto done; -- ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ OpenOCD-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openocd-devel
