Free the buffer before return. Also check the malloc return value. Perhaps it's not a good idea to exit() on error, but it's in line with the rest of the function.
Strange thing with this function is that the allocated buffer doesn't seem to be used for anything. The data read into it doesn't go anywhere. Maybe the entire function is flawed, or is the data really supposed to be discarded? Signed-off-by: Andreas Fritiofson <[email protected]> --- src/jtag/drivers/ft2232.c | 8 ++++++++ 1 files changed, 8 insertions(+), 0 deletions(-) diff --git a/src/jtag/drivers/ft2232.c b/src/jtag/drivers/ft2232.c index a3b87c3..9fb4d48 100644 --- a/src/jtag/drivers/ft2232.c +++ b/src/jtag/drivers/ft2232.c @@ -1142,6 +1142,12 @@ static int ft2232_large_scan(struct scan_command* cmd, enum scan_type type, uint int retval; int thisrun_read = 0; + if (!receive_buffer) + { + LOG_ERROR("failed to allocate memory"); + exit(-1); + } + if (cmd->ir_scan) { LOG_ERROR("BUG: large IR scans are not supported"); @@ -1341,6 +1347,8 @@ static int ft2232_large_scan(struct scan_command* cmd, enum scan_type type, uint receive_pointer += bytes_read; } + free(receive_buffer); + return ERROR_OK; } -- 1.7.0.4 _______________________________________________ Openocd-development mailing list [email protected] https://lists.berlios.de/mailman/listinfo/openocd-development
