Skip to content

Commit

Permalink
marshal: fix marshalling of ints with a wrong type (apache#1058)
Browse files Browse the repository at this point in the history
When trying to marshal a value with the wrong type into a
int, smallint or tinyint, marshalInt, marshalSmallint and marshalTinyint
fail with a panic because IsNil is called on a non-pointer value.
  • Loading branch information
vrischmann authored and Zariel committed Feb 5, 2018
1 parent dd47639 commit 1303a32
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions marshal.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ func marshalSmallInt(info TypeInfo, value interface{}) ([]byte, error) {
return nil, marshalErrorf("marshal smallint: value %d out of range", v)
}
return encShort(int16(v)), nil
default:
case reflect.Ptr:
if rv.IsNil() {
return nil, nil
}
Expand Down Expand Up @@ -414,7 +414,7 @@ func marshalTinyInt(info TypeInfo, value interface{}) ([]byte, error) {
return nil, marshalErrorf("marshal tinyint: value %d out of range", v)
}
return []byte{byte(v)}, nil
default:
case reflect.Ptr:
if rv.IsNil() {
return nil, nil
}
Expand Down Expand Up @@ -486,7 +486,7 @@ func marshalInt(info TypeInfo, value interface{}) ([]byte, error) {
return nil, marshalErrorf("marshal int: value %d out of range", v)
}
return encInt(int32(v)), nil
default:
case reflect.Ptr:
if rv.IsNil() {
return nil, nil
}
Expand Down

0 comments on commit 1303a32

Please sign in to comment.