Skip to content

Commit

Permalink
fix: corrupted stack slot in _op_switch when case-sensitive
Browse files Browse the repository at this point in the history
  • Loading branch information
liuq19 committed Jan 3, 2025
1 parent 5a6fb2f commit 9998182
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 0 additions & 1 deletion decoder/decoder_native_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ func TestDecoder_OptionCaseSensitiveForManyKeys(t *testing.T) {

var obj2 = TS{}
d := NewDecoder(js)
// d.SetOptions(OptionCaseSensitive)
err2 := d.Decode(&obj2)
require.NoError(t, err2)
require.Equal(t, obj, obj2)
Expand Down
3 changes: 3 additions & 0 deletions internal/decoder/jitdec/assembler_regabi_amd64.go
Original file line number Diff line number Diff line change
Expand Up @@ -1799,6 +1799,9 @@ func (self *_Assembler) _asm_OP_struct_field(p *_Instr) {
self.Emit("TESTQ", _AX, _AX) // TESTQ AX, AX
self.Sjmp("JNS" , "_end_{n}") // JNS _end_{n}
self.Link("_unknown_{n}")
// HACK: because `_VAR_sr` maybe used in `F_vstring`, so we should clear here again for `_OP_switch`.
self.Emit("MOVQ" , jit.Imm(-1), _AX) // MOVQ $-1, AX
self.Emit("MOVQ" , _AX, _VAR_sr) // MOVQ AX, sr
self.Emit("BTQ" , jit.Imm(_F_disable_unknown), _ARG_fv) // BTQ ${_F_disable_unknown}, fv
self.Sjmp("JC" , _LB_field_error) // JC _field_error
self.Link("_end_{n}") // _end_{n}:
Expand Down

0 comments on commit 9998182

Please sign in to comment.