mirror of
https://github.com/gbdev/rgbds.git
synced 2026-09-20 12:47:06 +00:00
Avoid signed overflow in RGBLINK's +, -, and * (#2060)
RGBASM computes these with unsigned arithmetic and casts back, since signed overflow is UB in C++, but RGBLINK's RPN evaluator used `int32_t` directly, so `src/link/patch.cpp` tripped UBSan on lines 117, 121, and 124. Share the three operators through `opmath.cpp` so both evaluators stay in step.
This commit is contained in:
@@ -5,6 +5,9 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
int32_t op_add(int32_t augend, int32_t addend);
|
||||
int32_t op_sub(int32_t minuend, int32_t subtrahend);
|
||||
int32_t op_mul(int32_t multiplicand, int32_t multiplier);
|
||||
int32_t op_divide(int32_t dividend, int32_t divisor);
|
||||
int32_t op_modulo(int32_t dividend, int32_t divisor);
|
||||
int32_t op_exponent(int32_t base, uint32_t power);
|
||||
|
||||
Reference in New Issue
Block a user