Fix signed left shift in vm_loop().
Signed left shift operations are undefined in C. Add constants for the minimum/maximum integer value which are already shifted. Technically, the constant for the shifted maximum value is not required, adding it for consistency/increased readability. The bug was detected by -Wshift-negative-value both with GCC 6.x and Clang. This fixes #1174. JerryScript-DCO-1.0-Signed-off-by: Tilmann Scheller t.scheller@samsung.com
This commit is contained in:
+2
-2
@@ -1215,12 +1215,12 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
|
||||
|
||||
if (opcode_flags & VM_OC_DECREMENT_OPERATOR_FLAG)
|
||||
{
|
||||
if (int_value > (ECMA_INTEGER_NUMBER_MIN << ECMA_DIRECT_SHIFT))
|
||||
if (int_value > ECMA_INTEGER_NUMBER_MIN_SHIFTED)
|
||||
{
|
||||
int_increase = -(1 << ECMA_DIRECT_SHIFT);
|
||||
}
|
||||
}
|
||||
else if (int_value < (ECMA_INTEGER_NUMBER_MAX << ECMA_DIRECT_SHIFT))
|
||||
else if (int_value < ECMA_INTEGER_NUMBER_MAX_SHIFTED)
|
||||
{
|
||||
int_increase = 1 << ECMA_DIRECT_SHIFT;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user