hsjsstn commented on issue #398:
URL:
https://github.com/apache/dubbo-go-hessian2/issues/398#issuecomment-6267287542
Came back with a repro.
```go
func TestPanicFloat(t *testing.T) {
v, err := ConvertSliceValueType(reflect.TypeOf([]float64{}),
reflect.ValueOf([]interface{}{"abc"}))
t.Logf("returned %v, %v", v, err)
}
```
```
panic: reflect: call of reflect.Value.Float on string Value
reflect.Value.Float(...)
github.com/apache/dubbo-go-hessian2.ConvertSliceValueType
codec.go:523
```
[]int64 and []uint32 destinations fail the same way.
Agreed on recover, and I wasn’t asking for validation across the decoder.
Just this switch: the accessor is picked from the destination kind, but
itemValue.Float() panics unless the source is a float kind. validateFloatKind /
validateIntKind / validateUintKind are already in the same file, just never
applied to itemValue.Kind() — so checking both sides and returning the error
the function already returns is a few lines, not a refactor.
SetValue and SetValueToPtrDest key off the destination type the same way,
FWIW.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]