diff options
author | Lee Duncan <lduncan@suse.com> | 2020-02-20 14:13:58 -0800 |
---|---|---|
committer | Lee Duncan <lduncan@suse.com> | 2020-02-20 14:13:58 -0800 |
commit | 3233e65e33c39818da46b891ea7b766a4e236c58 (patch) | |
tree | 82205a9e0824849f3ae5acc86143b2b44d4ca06e /libopeniscsiusr | |
parent | 44d7058555cd8498d1086db0464b169f4a988282 (diff) | |
download | open-iscsi-3233e65e33c39818da46b891ea7b766a4e236c58.tar.gz |
Fix memory leaks in libopeniscsiusr/idbm.c
Running "make check" in the libopeniscsiusr directory found
two memory leaks. The fix was to free the memory.
Diffstat (limited to 'libopeniscsiusr')
-rw-r--r-- | libopeniscsiusr/idbm.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/libopeniscsiusr/idbm.c b/libopeniscsiusr/idbm.c index 05cb7f9..7bc2381 100644 --- a/libopeniscsiusr/idbm.c +++ b/libopeniscsiusr/idbm.c @@ -608,7 +608,7 @@ static int _idbm_rec_update_param(struct iscsi_context *ctx, int passwd_done = 0; char passwd_len[8]; struct int_list_tbl *tbl = NULL; - char *tmp_value; + char *tmp_value, *orig_tmp_value; int *tmp_data; bool *found; char *token; @@ -693,7 +693,7 @@ setup_passwd_len: continue; tbl = (void *)recs[i].opts[0]; /* strsep is destructive, make a copy to work with */ - tmp_value = strdup(value); + orig_tmp_value = tmp_value = strdup(value); k = 0; tmp_data = malloc(recs[i].data_len); memset(tmp_data, ~0, recs[i].data_len); @@ -722,10 +722,12 @@ next_token: while ((token = strsep(&tmp_value, ", \n"))) { _warn(ctx, "Ignoring unknown value '%s'" " for '%s'", token, recs[i].name); } + free(found); + found = NULL; + free(orig_tmp_value); + orig_tmp_value = NULL; memcpy(recs[i].data, tmp_data, recs[i].data_len); - free(tmp_value); free(tmp_data); - tmp_value = NULL; tmp_data = NULL; token = NULL; goto updated; |