Commit bf5f21e3 authored by oharboe's avatar oharboe
Browse files

Steve Grubb <sgrubb@redhat.com> fix various and sundry leaks

git-svn-id: svn://svn.berlios.de/openocd/trunk@2606 b42882b7-edfa-0310-969c-e2dbd0fdcd60
parent 332c8d78
......@@ -117,6 +117,10 @@ static int script_command(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
words[i] = strdup(w);
if (words[i] == NULL)
{
int j;
for (j = 0; j < i; j++)
free(words[j]);
free(words);
return JIM_ERR;
}
}
......
......@@ -220,6 +220,7 @@ static int jim_newtap_cmd(Jim_GetOptInfo *goi)
* */
if (goi->argc < 3) {
Jim_SetResult_sprintf(goi->interp, "Missing CHIP TAP OPTIONS ....");
free(pTap);
return JIM_ERR;
}
Jim_GetOpt_String(goi, &cp, NULL);
......@@ -249,6 +250,8 @@ static int jim_newtap_cmd(Jim_GetOptInfo *goi)
e = Jim_GetOpt_Nvp(goi, opts, &n);
if (e != JIM_OK) {
Jim_GetOpt_NvpUnknown(goi, opts, 0);
free((void *)pTap->dotted_name);
free(pTap);
return e;
}
LOG_DEBUG("Processing option: %s", n->name);
......@@ -266,12 +269,16 @@ static int jim_newtap_cmd(Jim_GetOptInfo *goi)
e = Jim_GetOpt_Wide(goi, &w);
if (e != JIM_OK) {
Jim_SetResult_sprintf(goi->interp, "option: %s bad parameter", n->name);
free((void *)pTap->dotted_name);
free(pTap);
return e;
}
new_expected_ids = malloc(sizeof(uint32_t) * (pTap->expected_ids_cnt + 1));
if (new_expected_ids == NULL) {
Jim_SetResult_sprintf(goi->interp, "no memory");
free((void *)pTap->dotted_name);
free(pTap);
return JIM_ERR;
}
......@@ -290,6 +297,8 @@ static int jim_newtap_cmd(Jim_GetOptInfo *goi)
e = Jim_GetOpt_Wide(goi, &w);
if (e != JIM_OK) {
Jim_SetResult_sprintf(goi->interp, "option: %s bad parameter", n->name);
free((void *)pTap->dotted_name);
free(pTap);
return e;
}
switch (n->value) {
......@@ -303,6 +312,8 @@ static int jim_newtap_cmd(Jim_GetOptInfo *goi)
if (is_bad_irval(pTap->ir_length, w)) {
LOG_ERROR("IR mask %x too big",
(int) w);
free((void *)pTap->dotted_name);
free(pTap);
return ERROR_FAIL;
}
pTap->ir_capture_mask = w;
......@@ -312,6 +323,8 @@ static int jim_newtap_cmd(Jim_GetOptInfo *goi)
if (is_bad_irval(pTap->ir_length, w)) {
LOG_ERROR("IR capture %x too big",
(int) w);
free((void *)pTap->dotted_name);
free(pTap);
return ERROR_FAIL;
}
pTap->ir_capture_value = w;
......@@ -1144,7 +1157,12 @@ static int handle_irscan_command(struct command_context_s *cmd_ctx, char *cmd, c
tap = jtag_tap_by_string(args[i*2]);
if (tap == NULL)
{
int j;
for (j = 0; j < i; j++)
free(fields[j].out_value);
free(fields);
command_print(cmd_ctx, "Tap: %s unknown", args[i*2]);
return ERROR_FAIL;
}
int field_size = tap->ir_length;
......
......@@ -435,6 +435,7 @@ struct usbprog_jtag* usbprog_jtag_open(void)
}
}
}
free(tmp);
return 0;
}
......
......@@ -597,6 +597,7 @@ int telnet_init(char *banner)
if (telnet_port == 0)
{
LOG_INFO("telnet port disabled");
free(telnet_service);
return ERROR_OK;
}
......
......@@ -1322,6 +1322,7 @@ static int svf_run_command(struct command_context_s *cmd_ctx, char *cmd_str)
if (!svf_tap_state_is_valid(path[i]))
{
LOG_ERROR("%s is not valid state", svf_tap_state_name[path[i]]);
free(path);
return ERROR_FAIL;
}
if (TAP_RESET == path[i])
......@@ -1348,6 +1349,7 @@ static int svf_run_command(struct command_context_s *cmd_ctx, char *cmd_str)
else
{
LOG_ERROR("%s is not valid state", svf_tap_state_name[path[num_of_argu - 1]]);
free(path);
return ERROR_FAIL;
}
}
......
......@@ -197,6 +197,7 @@ reg_cache_t* embeddedice_build_reg_cache(target_t *target, arm7_9_common_t *arm7
free(reg_list[i].value);
}
free(reg_list);
free(reg_cache);
free(arch_info);
return NULL;
}
......
......@@ -246,6 +246,12 @@ reg_cache_t* etm_build_reg_cache(target_t *target, arm_jtag_t *jtag_info, etm_co
if (!etb)
{
LOG_ERROR("etb selected as etm capture driver, but no ETB configured");
for (i = 0; i < num_regs; i++)
{
free(reg_list[i].value);
}
free(reg_cache);
free(arch_info);
return ERROR_OK;
}
......@@ -1202,6 +1208,7 @@ static int handle_etm_config_command(struct command_context_s *cmd_ctx, char *cm
if (argc != 5)
{
free(etm_ctx);
return ERROR_COMMAND_SYNTAX_ERROR;
}
......@@ -1209,12 +1216,14 @@ static int handle_etm_config_command(struct command_context_s *cmd_ctx, char *cm
if (!target)
{
LOG_ERROR("target '%s' not defined", args[0]);
free(etm_ctx);
return ERROR_FAIL;
}
if (arm7_9_get_arch_pointers(target, &armv4_5, &arm7_9) != ERROR_OK)
{
command_print(cmd_ctx, "current target isn't an ARM7/ARM9 target");
free(etm_ctx);
return ERROR_FAIL;
}
......@@ -1231,6 +1240,7 @@ static int handle_etm_config_command(struct command_context_s *cmd_ctx, char *cm
break;
default:
command_print(cmd_ctx, "unsupported ETM port width '%s', must be 4, 8 or 16", args[1]);
free(etm_ctx);
return ERROR_FAIL;
}
......@@ -1249,6 +1259,7 @@ static int handle_etm_config_command(struct command_context_s *cmd_ctx, char *cm
else
{
command_print(cmd_ctx, "unsupported ETM port mode '%s', must be 'normal', 'multiplexed' or 'demultiplexed'", args[2]);
free(etm_ctx);
return ERROR_FAIL;
}
......@@ -1263,6 +1274,7 @@ static int handle_etm_config_command(struct command_context_s *cmd_ctx, char *cm
else
{
command_print(cmd_ctx, "unsupported ETM port clocking '%s', must be 'full' or 'half'", args[3]);
free(etm_ctx);
return ERROR_FAIL;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment