Commit 2c80ac82 authored by Kirill Smelkov's avatar Kirill Smelkov

.

parent e7174feb
...@@ -231,8 +231,9 @@ func (p *XXXTest) NEODecode(data []byte) (int, error) { ...@@ -231,8 +231,9 @@ func (p *XXXTest) NEODecode(data []byte) (int, error) {
data = data[l:] data = data[l:]
} }
} }
nread += l * 8
} }
return 20 + int(nread), nil return 12 + int(nread), nil
overflow: overflow:
return 0, ErrDecodeOverflow return 0, ErrDecodeOverflow
......
...@@ -244,6 +244,10 @@ func TestPktMarshal(t *testing.T) { ...@@ -244,6 +244,10 @@ func TestPktMarshal(t *testing.T) {
hex("3fbf9add1091c895"), hex("3fbf9add1091c895"),
}, },
// TODO we need tests for:
// []varsize + trailing
// map[]varsize + trailing
// TODO special cases for: // TODO special cases for:
// - float64 (+ nan !nan ...) // - float64 (+ nan !nan ...)
......
...@@ -869,7 +869,12 @@ func (d *decoder) genMap(assignto string, typ *types.Map, obj types.Object) { ...@@ -869,7 +869,12 @@ func (d *decoder) genMap(assignto string, typ *types.Map, obj types.Object) {
d.emit("m := %v", assignto) d.emit("m := %v", assignto)
d.emit("for i := 0; uint32(i) < l; i++ {") d.emit("for i := 0; uint32(i) < l; i++ {")
d.overflowCheckPoint() d.overflowCheckPoint() // -> overflowCheckPointLoopEntry ?
var nreadCur int
if !d.overflowCheck.checked { // TODO merge-in into overflow checker
nreadCur = d.nread
d.nread = 0
}
codegenType("key:", typ.Key(), obj, d) codegenType("key:", typ.Key(), obj, d)
...@@ -888,8 +893,15 @@ func (d *decoder) genMap(assignto string, typ *types.Map, obj types.Object) { ...@@ -888,8 +893,15 @@ func (d *decoder) genMap(assignto string, typ *types.Map, obj types.Object) {
d.resetPos() d.resetPos()
d.emit("}") d.emit("}")
d.overflowCheckPoint() // -> overflowCheckPointLoopExit("l") ?
// TODO overflowCheckPointLoopExit("l") // merge-in numeric nread updates from loop
if !d.overflowCheck.checked {
if d.nread != 0 {
d.emit("%v += l * %v", d.var_("nread"), d.nread)
}
d.nread = nreadCur
}
d.emit("}") d.emit("}")
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment