This is an automated email from Gerrit. Marc Schink ([email protected]) just uploaded a new patch set to Gerrit, which you can find at http://openocd.zylin.com/2998
-- gerrit commit 31e86d662a26c001c058a3517f75114b79366ffe Author: Marc Schink <[email protected]> Date: Fri Oct 2 17:12:17 2015 +0200 helper/fileio: Fix memory leak. The memory leak occurs when opening a file fails. It can be reproduced by using the "flash verify_bank" command with a filename that does not exist. Change-Id: I60b7b545c18793d750ff75d08124fde3f0aa6f64 Signed-off-by: Marc Schink <[email protected]> diff --git a/src/helper/fileio.c b/src/helper/fileio.c index c6f45e6..f6b8a93 100644 --- a/src/helper/fileio.c +++ b/src/helper/fileio.c @@ -105,10 +105,10 @@ int fileio_open(struct fileio *fileio_p, enum fileio_access access_type, enum fileio_type type) { - int retval = ERROR_OK; + int retval; + struct fileio_internal *fileio; - struct fileio_internal *fileio = malloc(sizeof(struct fileio_internal)); - fileio_p->fp = fileio; + fileio = malloc(sizeof(struct fileio_internal)); fileio->type = type; fileio->access = access_type; @@ -116,7 +116,15 @@ int fileio_open(struct fileio *fileio_p, retval = fileio_open_local(fileio); - return retval; + if (retval != ERROR_OK) { + free(fileio->url); + free(fileio); + return retval; + } + + fileio_p->fp = fileio; + + return ERROR_OK; } static inline int fileio_close_local(struct fileio_internal *fileio) -- ------------------------------------------------------------------------------ _______________________________________________ OpenOCD-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/openocd-devel
