2
0
Fork 0
mirror of https://github.com/ii64/sonic.git synced 2026-06-23 01:46:44 +08:00

fix: (decoder) return io.EOF when read nothing from io.Reader (#254)

* fix: (decoder) return io.EOF when read nothing from io.Reader

* build:(CI) codeql-analysis only use x86 machine
This commit is contained in:
Yi Duan 2022-07-01 17:51:42 +08:00 committed by GitHub
parent fc6f3743fd
commit 55e3d10619
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 1 deletions

View file

@ -23,7 +23,7 @@ on:
jobs: jobs:
analyze: analyze:
name: Analyze name: Analyze
runs-on: self-hosted runs-on: [self-hosted, X64]
permissions: permissions:
actions: read actions: read
contents: read contents: read

View file

@ -80,6 +80,9 @@ read_more:
if err != nil { if err != nil {
repeat = false repeat = false
if err == io.EOF { if err == io.EOF {
if len(buf) == 0 {
return err
}
break break
} }
self.err = err self.err = err

View file

@ -35,6 +35,20 @@ var (
strings.Repeat("2",1024)+`"} b {}` strings.Repeat("2",1024)+`"} b {}`
) )
func TestDecodeEmpty(t *testing.T) {
var str = ``
var r1 = strings.NewReader(str)
var v1 interface{}
var d1 = json.NewDecoder(r1)
var r2 = strings.NewReader(str)
var v2 interface{}
var d2 = NewStreamDecoder(r2)
es1 := d1.Decode(&v1)
ee1 := d2.Decode(&v2)
assert.Equal(t, es1, ee1)
assert.Equal(t, v1, v2)
}
func TestDecodeSingle(t *testing.T) { func TestDecodeSingle(t *testing.T) {
var str = _Single_JSON var str = _Single_JSON