mirror of
https://github.com/ii64/sonic.git
synced 2026-06-21 00:46:43 +08:00
fix:(encoder) insufficient buffer size check for OP_i32 (#269)
This commit is contained in:
parent
2eae594741
commit
8b51e75241
3 changed files with 35 additions and 15 deletions
|
|
@ -819,7 +819,7 @@ func (self *_Assembler) _asm_OP_i16(_ *_Instr) {
|
|||
}
|
||||
|
||||
func (self *_Assembler) _asm_OP_i32(_ *_Instr) {
|
||||
self.store_int(11, _F_i64toa, "MOVLQSX")
|
||||
self.store_int(17, _F_i64toa, "MOVLQSX")
|
||||
}
|
||||
|
||||
func (self *_Assembler) _asm_OP_i64(_ *_Instr) {
|
||||
|
|
@ -835,7 +835,7 @@ func (self *_Assembler) _asm_OP_u16(_ *_Instr) {
|
|||
}
|
||||
|
||||
func (self *_Assembler) _asm_OP_u32(_ *_Instr) {
|
||||
self.store_int(10, _F_u64toa, "MOVLQZX")
|
||||
self.store_int(16, _F_u64toa, "MOVLQZX")
|
||||
}
|
||||
|
||||
func (self *_Assembler) _asm_OP_u64(_ *_Instr) {
|
||||
|
|
|
|||
|
|
@ -832,7 +832,7 @@ func (self *_Assembler) _asm_OP_i16(_ *_Instr) {
|
|||
}
|
||||
|
||||
func (self *_Assembler) _asm_OP_i32(_ *_Instr) {
|
||||
self.store_int(11, _F_i64toa, "MOVLQSX")
|
||||
self.store_int(17, _F_i64toa, "MOVLQSX")
|
||||
}
|
||||
|
||||
func (self *_Assembler) _asm_OP_i64(_ *_Instr) {
|
||||
|
|
@ -848,7 +848,7 @@ func (self *_Assembler) _asm_OP_u16(_ *_Instr) {
|
|||
}
|
||||
|
||||
func (self *_Assembler) _asm_OP_u32(_ *_Instr) {
|
||||
self.store_int(10, _F_u64toa, "MOVLQZX")
|
||||
self.store_int(16, _F_u64toa, "MOVLQZX")
|
||||
}
|
||||
|
||||
func (self *_Assembler) _asm_OP_u64(_ *_Instr) {
|
||||
|
|
|
|||
|
|
@ -17,20 +17,40 @@
|
|||
package encoder
|
||||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"math"
|
||||
"reflect"
|
||||
"runtime"
|
||||
"strings"
|
||||
"testing"
|
||||
"unsafe"
|
||||
`encoding/hex`
|
||||
`encoding/json`
|
||||
`math`
|
||||
`reflect`
|
||||
`runtime`
|
||||
`strings`
|
||||
`testing`
|
||||
`unsafe`
|
||||
|
||||
"github.com/bytedance/sonic/internal/rt"
|
||||
"github.com/davecgh/go-spew/spew"
|
||||
"github.com/stretchr/testify/assert"
|
||||
`github.com/bytedance/sonic/internal/rt`
|
||||
`github.com/davecgh/go-spew/spew`
|
||||
`github.com/stretchr/testify/assert`
|
||||
)
|
||||
|
||||
func TestEncoderMemoryCorruption(t *testing.T) {
|
||||
println("TestEncoderMemoryCorruption")
|
||||
var m = map[string]interface{}{
|
||||
"1": map[string]interface{} {
|
||||
`"`+strings.Repeat("a", _MaxBuffer - 38)+`"`: "b",
|
||||
"1": map[string]int32{
|
||||
"b": 1658219785,
|
||||
},
|
||||
},
|
||||
}
|
||||
out, err := Encode(m, SortMapKeys)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
println(len(out))
|
||||
if err := json.Unmarshal(out, &m); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestAssembler_CompileAndLoad(t *testing.T) {
|
||||
p, err := newCompiler().compile(reflect.TypeOf((*bool)(nil)))
|
||||
assert.Nil(t, err)
|
||||
|
|
|
|||
Loading…
Reference in a new issue