diff --git a/src/cli.c b/src/cli.c index 7cda5c0..e8acb4c 100644 --- a/src/cli.c +++ b/src/cli.c @@ -427,6 +427,10 @@ static int upload_file(storj_env_t *env, char *bucket_id, const char *file_path) progress_cb, upload_file_complete); + if (!state) { + return 1; + } + sig->data = state; return state->error_status; @@ -514,6 +518,9 @@ static int download_file(storj_env_t *env, char *bucket_id, file_id, fd, NULL, progress_cb, download_file_complete); + if (!state) { + return 1; + } sig->data = state; return state->error_status; diff --git a/test/tests.c b/test/tests.c index a8fd638..6a0609e 100644 --- a/test/tests.c +++ b/test/tests.c @@ -534,10 +534,11 @@ int test_upload() NULL, check_store_file_progress, check_store_file); - assert(state->error_status == 0); + if (!state || state->error_status != 0) { + return 1; + } // run all queued events - if (uv_run(env->loop, UV_RUN_DEFAULT)) { return 1; } @@ -580,8 +581,9 @@ int test_upload_cancel() NULL, check_store_file_progress, check_store_file_cancel); - assert(state->error_status == 0); - + if (!state || state->error_status != 0) { + return 1; + } // process the loop one at a time so that we can do other things while // the loop is processing, such as cancel the download @@ -639,9 +641,11 @@ int test_download() check_resolve_file_progress, check_resolve_file); - free(download_file); + if (!state || state->error_status != 0) { + return 1; + } - assert(state->error_status == 0); + free(download_file); if (uv_run(env->loop, UV_RUN_DEFAULT)) { return 1; @@ -679,7 +683,9 @@ int test_download_cancel() check_resolve_file_progress, check_resolve_file_cancel); - assert(state->error_status == 0); + if (!state || state->error_status != 0) { + return 1; + } // process the loop one at a time so that we can do other things while // the loop is processing, such as cancel the download