From 0a15a7d70b940c7c95ed528f0d60b9377b49435c Mon Sep 17 00:00:00 2001 From: gavinhgchen Date: Tue, 21 Jun 2022 21:31:55 +0800 Subject: [PATCH] fix the possible crash in cos_resumable_download_file() --- cos_c_sdk/cos_resumable.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cos_c_sdk/cos_resumable.c b/cos_c_sdk/cos_resumable.c index 2161bd8..056f60b 100644 --- a/cos_c_sdk/cos_resumable.c +++ b/cos_c_sdk/cos_resumable.c @@ -1116,6 +1116,13 @@ void * APR_THREAD_FUNC download_part(apr_thread_t *thd, void *data) cos_debug_log("download part = %d, start byte = %"APR_INT64_T_FMT", end byte = %"APR_INT64_T_FMT, part_num, download_file->file_pos, download_file->file_last-1); + if (!cos_status_is_ok(s)) { + apr_atomic_inc32(params->failed); + params->result->s = s; + apr_queue_push(params->failed_parts, params->result); + return s; + } + etag = apr_pstrdup(params->options.pool, (char*)apr_table_get(resp_headers, "ETag")); cos_str_set(¶ms->result->etag, etag); params->result->crc64 = resp->crc64;