Skip to content

Commit

Permalink
Fix UB in left-shifts in the M2/M3/M4 macros (bellard#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
trufae authored Jan 26, 2023
1 parent 03fd974 commit 975d74d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -30622,9 +30622,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) | ((op2) << 8))
#define M3(op1, op2, op3) (uint32_t)((op1) | ((op2 & 0xff) << 8) | ((op3 & 0xff) << 16))
#define M4(op1, op2, op3, op4) (uint32_t)((op1) | ((uint32_t)(op2 & 0xff) << 8) | ((uint32_t)(op3 & 0xff) << 16) | ((uint32_t)(op4 & 0xff) << 24))

static BOOL code_match(CodeContext *s, int pos, ...)
{
Expand Down

0 comments on commit 975d74d

Please sign in to comment.