@@ -168,6 +168,12 @@ static int s_aws_s3_part_streaming_input_stream_read(struct aws_input_stream *st
168168 AWS_CONTAINER_OF (stream , struct aws_s3_part_streaming_input_stream_impl , base );
169169 int rt = aws_input_stream_read (test_input_stream -> base_stream , dest );
170170 test_input_stream -> length_read += dest -> len ;
171+ if (test_input_stream -> length_read > test_input_stream -> total_length ) {
172+ size_t gap = test_input_stream -> length_read - test_input_stream -> total_length ;
173+ size_t new_len = dest -> len - gap ;
174+ dest -> len = new_len ;
175+ test_input_stream -> length_read = test_input_stream -> total_length ;
176+ }
171177 return rt ;
172178}
173179
@@ -226,13 +232,12 @@ struct aws_input_stream *aws_input_stream_new_from_parallel(
226232 & test_input_stream -> base .ref_count ,
227233 test_input_stream ,
228234 (aws_simple_completion_callback * )s_aws_s3_part_streaming_input_stream_destroy );
229-
235+ test_input_stream -> allocator = allocator ;
230236 test_input_stream -> base .vtable = & s_aws_s3_part_streaming_input_stream_vtable ;
231- struct aws_parallel_input_stream_from_file_impl * impl = parallel_stream -> impl ;
232- aws_mem_calloc (allocator , 1 , sizeof (struct aws_parallel_input_stream_from_file_impl ));
233- aws_parallel_input_stream_init_base (& impl -> base , allocator , & s_parallel_input_stream_from_file_vtable , impl );
234237
238+ struct aws_parallel_input_stream_from_file_impl * impl = parallel_stream -> impl ;
235239 test_input_stream -> base_stream = aws_input_stream_new_from_file (allocator , aws_string_c_str (impl -> file_path ));
240+ AWS_FATAL_ASSERT (test_input_stream -> base_stream != NULL );
236241 test_input_stream -> total_length = request_body_size ;
237242 test_input_stream -> offset = offset ;
238243 test_input_stream -> length_read = 0 ;
0 commit comments