diff options
author | Lee Duncan <leeman.duncan@gmail.com> | 2020-02-20 14:24:07 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-20 14:24:07 -0800 |
commit | 26ad7ca79b953ef2633a70f1dec42565aa085323 (patch) | |
tree | 4f2ed96acb492a3b80cb9e93d17c431f401a46e5 | |
parent | fce02a13fd3028df3acf80e1439f85b800f237b6 (diff) | |
parent | 3233e65e33c39818da46b891ea7b766a4e236c58 (diff) | |
download | open-iscsi-26ad7ca79b953ef2633a70f1dec42565aa085323.tar.gz |
Merge pull request #189 from gonzoleeman/fix-libopeniscsiusr-valgrind
Fix memory leaks in libopeniscsiusr/idbm.c
-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; |