Commit cb009a5c authored by Felix Lange's avatar Felix Lange

rlp: don't panic for nil *big.Int

All other pointer types can handle nil just fine.
parent 86661de0
......@@ -386,7 +386,12 @@ func writeUint(val reflect.Value, w *encbuf) error {
}
func writeBigIntPtr(val reflect.Value, w *encbuf) error {
return writeBigInt(val.Interface().(*big.Int), w)
ptr := val.Interface().(*big.Int)
if ptr == nil {
w.str = append(w.str, 0x80)
return nil
}
return writeBigInt(ptr, w)
}
func writeBigIntNoPtr(val reflect.Value, w *encbuf) error {
......
......@@ -196,6 +196,7 @@ var encTests = []encTest{
{val: (*uint)(nil), output: "80"},
{val: (*string)(nil), output: "80"},
{val: (*[]byte)(nil), output: "80"},
{val: (*big.Int)(nil), output: "80"},
{val: (*[]string)(nil), output: "C0"},
{val: (*[]interface{})(nil), output: "C0"},
{val: (*[]struct{ uint })(nil), output: "C0"},
......
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