File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -341,8 +341,13 @@ int hdr_calculate_bucket_config(
341341 sub_bucket_count_magnitude = (int32_t ) ceil (log ((double )largest_value_with_single_unit_resolution ) / log (2 ));
342342 cfg -> sub_bucket_half_count_magnitude = ((sub_bucket_count_magnitude > 1 ) ? sub_bucket_count_magnitude : 1 ) - 1 ;
343343
344- cfg -> unit_magnitude = (int32_t ) floor (log ((double )lowest_trackable_value ) / log (2 ));
344+ double unit_magnitude = log ((double )lowest_trackable_value ) / log (2 );
345+ if (INT32_MAX < unit_magnitude )
346+ {
347+ return EINVAL ;
348+ }
345349
350+ cfg -> unit_magnitude = (int32_t ) unit_magnitude ;
346351 cfg -> sub_bucket_count = (int32_t ) pow (2 , (cfg -> sub_bucket_half_count_magnitude + 1 ));
347352 cfg -> sub_bucket_half_count = cfg -> sub_bucket_count / 2 ;
348353 cfg -> sub_bucket_mask = ((int64_t ) cfg -> sub_bucket_count - 1 ) << cfg -> unit_magnitude ;
You can’t perform that action at this time.
0 commit comments