You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: add safe double-to-int64 conversion for bitwise operations
Implements proper safety checks for all bitwise operations (<<, >>, &, ^, |)
when converting double values to int64_t. This prevents undefined behavior
and potential security issues from integer overflow or invalid values.
The implementation:
- Adds safeDoubleToInt64 function with proper range validation
- Applies this function to all bitwise operations
- Limits values to the safe integer range (±(2^53-1))
- Provides clear error messages with source location context
The safe integer range limitation is necessary because IEEE 754 doubles
can only precisely represent integers up to 2^53-1. Beyond this range,
precision is lost, which would lead to unpredictable results in bitwise
operations that depend on exact bit patterns.
This change aligns with the Jsonnet specification which requires bitwise
operations to convert operands to signed 64-bit integers before performing
operations, while ensuring mathematical correctness.
Signed-off-by: Ville Vesilehto <[email protected]>
0 commit comments