Skip to content

Commit

Permalink
handle zero
Browse files Browse the repository at this point in the history
  • Loading branch information
TingDaoK committed Dec 12, 2023
1 parent f4ea31d commit 0b3b6c5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion source/s3_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1221,12 +1221,14 @@ static struct aws_s3_meta_request *s_s3_client_meta_request_factory_default(
}

uint32_t num_parts = 0;
size_t out_part_size = 0;
if (content_length_found) {
if (aws_s3_calculate_optimal_mpu_part_size_and_num_parts(
content_length, part_size, client_max_part_size, &part_size, &num_parts)) {
content_length, part_size, client_max_part_size, &out_part_size, &num_parts)) {
return NULL;
}
}
part_size = out_part_size;
if (part_size != options->part_size && part_size != client->part_size) {
AWS_LOGF_DEBUG(
AWS_LS_S3_META_REQUEST,
Expand Down
6 changes: 6 additions & 0 deletions source/s3_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,12 @@ int aws_s3_calculate_optimal_mpu_part_size_and_num_parts(
AWS_FATAL_ASSERT(out_part_size);
AWS_FATAL_ASSERT(out_num_parts);

if (content_length == 0) {
*out_part_size = 0;
*out_num_parts = 0;
return AWS_OP_SUCCESS;
}

uint64_t part_size_uint64 = content_length / (uint64_t)g_s3_max_num_upload_parts;

if ((content_length % g_s3_max_num_upload_parts) > 0) {
Expand Down

0 comments on commit 0b3b6c5

Please sign in to comment.