Skip to content

Commit 8f81439

Browse files
committed
JIT: fix register leak in first_pass_bs_match_equal_colon_equal
Fix a leak where a register was not properly freed on 32 bits platforms. Also fix a double free that happened on 32 bits platforms. This code currently is dead and is only evaluated when targeting riscv-32 and armv6m. Signed-off-by: Paul Guyot <[email protected]>
1 parent 14bf0d5 commit 8f81439

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

libs/jit/src/jit.erl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2976,14 +2976,14 @@ first_pass_bs_match_equal_colon_equal(
29762976
),
29772977
MSt4 = MMod:and_(MSt3, Result, ?TERM_PRIMARY_CLEAR_MASK),
29782978
{MSt5, IntValue} = MMod:get_array_element(MSt4, {free, Result}, 1),
2979-
cond_jump_to_label({IntValue, '!=', PatternValue}, Fail, MMod, MSt5);
2979+
cond_jump_to_label({{free, IntValue}, '!=', PatternValue}, Fail, MMod, MSt5);
29802980
_ ->
29812981
MSt4 = MMod:shift_right(MSt3, Result, 4),
2982-
cond_jump_to_label({Result, '!=', PatternValue}, Fail, MMod, MSt4)
2982+
MSt5 = cond_jump_to_label({Result, '!=', PatternValue}, Fail, MMod, MSt4),
2983+
MMod:free_native_registers(MSt5, [Result])
29832984
end,
29842985
MSt7 = MMod:add(MSt6, BSOffsetReg, Size),
2985-
MSt8 = MMod:free_native_registers(MSt7, [Result]),
2986-
{J0 - 3, Rest3, MatchState, BSOffsetReg, MSt8}.
2986+
{J0 - 3, Rest3, MatchState, BSOffsetReg, MSt7}.
29872987

29882988
first_pass_bs_match_skip(MatchState, BSOffsetReg, J0, Rest0, MMod, MSt0) ->
29892989
{Stride, Rest1} = decode_literal(Rest0),

0 commit comments

Comments
 (0)