From 8217c691570fb34bf5dadda958ac9197681300f9 Mon Sep 17 00:00:00 2001 From: Ben Noordhuis Date: Wed, 1 Nov 2023 04:46:16 +0100 Subject: [PATCH] Fix UB shift into sign bit --- quickjs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/quickjs.c b/quickjs.c index d662eb3..16c6760 100644 --- a/quickjs.c +++ b/quickjs.c @@ -30444,9 +30444,9 @@ typedef struct CodeContext { JSAtom atom; } CodeContext; -#define M2(op1, op2) ((op1) | ((op2) << 8)) -#define M3(op1, op2, op3) ((op1) | ((op2) << 8) | ((op3) << 16)) -#define M4(op1, op2, op3, op4) ((op1) | ((op2) << 8) | ((op3) << 16) | ((op4) << 24)) +#define M2(op1, op2) ((uint32_t)(op1) | ((uint32_t)(op2) << 8)) +#define M3(op1, op2, op3) ((uint32_t)(op1) | ((uint32_t)(op2) << 8) | ((uint32_t)(op3) << 16)) +#define M4(op1, op2, op3, op4) ((uint32_t)(op1) | ((uint32_t)(op2) << 8) | ((uint32_t)(op3) << 16) | ((uint32_t)(op4) << 24)) static BOOL code_match(CodeContext *s, int pos, ...) {