diff --git a/include/aws/s3/s3_client.h b/include/aws/s3/s3_client.h index 4a161ef62..1cd6d9c8b 100644 --- a/include/aws/s3/s3_client.h +++ b/include/aws/s3/s3_client.h @@ -421,8 +421,8 @@ struct aws_s3_client_config { /* Throughput target in gigabits per second (Gbps) that we are trying to reach. */ double throughput_target_gbps; - /* How much memory can we use. */ - size_t memory_limit_in_bytes; + /* How much memory can we use. This will be capped to SIZE_MAX */ + uint64_t memory_limit_in_bytes; /* Retry strategy to use. If NULL, a default retry strategy will be used. */ struct aws_retry_strategy *retry_strategy; diff --git a/source/s3_client.c b/source/s3_client.c index 6405a5412..d4eafcc22 100644 --- a/source/s3_client.c +++ b/source/s3_client.c @@ -342,7 +342,12 @@ struct aws_s3_client *aws_s3_client_new( } #endif } else { - mem_limit = client_config->memory_limit_in_bytes; + // cap memory limit to SIZE_MAX + if (client_config->memory_limit_in_bytes > SIZE_MAX) { + mem_limit = SIZE_MAX; + } else { + mem_limit = (size_t)client_config->memory_limit_in_bytes; + } } size_t part_size = s_default_part_size;