Fix for potential memory leakage and for unused/unreported return error code
Change-Id: Ifb2c95b60637c3a241ad4bf41d1a328c92ccea4b
Signed-off-by: Michele Sardo <msmttchr@gmail.com>
Reviewed-on: http://openocd.zylin.com/4476
Tested-by: jenkins
Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
if (pre_bytes) {
if (target_read_u32(target, pre_address, &pre_word)) {
LOG_ERROR("Memory read failed");
+ free(new_buffer);
return ERROR_FAIL;
}
if (post_bytes) {
if (target_read_u32(target, post_address, &post_word)) {
LOG_ERROR("Memory read failed");
+ free(new_buffer);
return ERROR_FAIL;
}
destroy_reg_param(®_params[2]);
destroy_reg_param(®_params[3]);
destroy_reg_param(®_params[4]);
+ if (retval != ERROR_OK)
+ return retval;
+
}
/* Program chunk at end, not addressable by fast burst write algorithm */