You've already forked json-iterator
							
							
				mirror of
				https://github.com/json-iterator/go.git
				synced 2025-10-31 00:07:40 +02:00 
			
		
		
		
	fix #263, support empty string as 0 in fuzz mode
This commit is contained in:
		| @@ -217,6 +217,9 @@ func (decoder *fuzzyIntegerDecoder) Decode(ptr unsafe.Pointer, iter *jsoniter.It | ||||
| 	default: | ||||
| 		iter.ReportError("fuzzyIntegerDecoder", "not number or string") | ||||
| 	} | ||||
| 	if len(str) == 0 { | ||||
| 		str = "0" | ||||
| 	} | ||||
| 	newIter := iter.Pool().BorrowIterator([]byte(str)) | ||||
| 	defer iter.Pool().ReturnIterator(newIter) | ||||
| 	isFloat := strings.IndexByte(str, '.') != -1 | ||||
|   | ||||
| @@ -37,6 +37,8 @@ func Test_any_to_int64(t *testing.T) { | ||||
| 	should.Equal(int64(10), val) | ||||
| 	should.Nil(jsoniter.UnmarshalFromString(`10`, &val)) | ||||
| 	should.Equal(int64(10), val) | ||||
| 	should.Nil(jsoniter.UnmarshalFromString(`""`, &val)) | ||||
| 	should.Equal(int64(0), val) | ||||
|  | ||||
| 	// bool part | ||||
| 	should.Nil(jsoniter.UnmarshalFromString(`false`, &val)) | ||||
|   | ||||
		Reference in New Issue
	
	Block a user