Skip to content
This repository was archived by the owner on Jul 2, 2021. It is now read-only.

Avoid double call to json_object_put #403

Merged
merged 1 commit into from
Nov 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,6 @@ static void list_files_callback(uv_work_t *work_req, int status)
}

cleanup:
json_object_put(req->response);
storj_free_list_files_request(req);
free(work_req);
exit(ret_status);
Expand Down Expand Up @@ -908,7 +907,6 @@ static void get_buckets_callback(uv_work_t *work_req, int status)
bucket->created, bucket->name);
}

json_object_put(req->response);
storj_free_get_buckets_request(req);
free(work_req);
}
Expand Down
12 changes: 9 additions & 3 deletions src/storj.c
Original file line number Diff line number Diff line change
Expand Up @@ -1198,7 +1198,9 @@ STORJ_API int storj_bridge_get_buckets(storj_env_t *env, void *handle, uv_after_

STORJ_API void storj_free_get_buckets_request(get_buckets_request_t *req)
{
json_object_put(req->response);
if (req->response) {
json_object_put(req->response);
}
if (req->buckets && req->total_buckets > 0) {
for (int i = 0; i < req->total_buckets; i++) {
free((char *)req->buckets[i].name);
Expand Down Expand Up @@ -1279,7 +1281,9 @@ STORJ_API int storj_bridge_get_bucket(storj_env_t *env,

STORJ_API void storj_free_get_bucket_request(get_bucket_request_t *req)
{
json_object_put(req->response);
if (req->response) {
json_object_put(req->response);
}
free(req->path);
if (req->bucket) {
free((char *)req->bucket->name);
Expand Down Expand Up @@ -1318,7 +1322,9 @@ STORJ_API int storj_bridge_list_files(storj_env_t *env,

STORJ_API void storj_free_list_files_request(list_files_request_t *req)
{
json_object_put(req->response);
if (req->response) {
json_object_put(req->response);
}
free(req->path);
if (req->files && req->total_files > 0) {
for (int i = 0; i < req->total_files; i++) {
Expand Down
1 change: 0 additions & 1 deletion src/uploader.c
Original file line number Diff line number Diff line change
Expand Up @@ -2133,7 +2133,6 @@ static void verify_bucket_id_callback(uv_work_t *work_req, int status)
clean_variables:
queue_next_work(state);

json_object_put(req->response);
storj_free_get_bucket_request(req);
free(work_req);
}
Expand Down