golang / protobuf

Go support for Google's protocol buffers

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Umarshal crashes with "call of reflect.Value.SetMapIndex on zero Value"

dvyukov opened this issue · comments

go version devel +87054c4 Wed Apr 22 02:50:48 2015 +0000 linux/amd64
golang/protobuf is on 655cdfa
protoc is on fe7b566

Protobuf is:

syntax = "proto2";

package main;

message M {
  map<int32, int32> f = 1;
}

Program is:

package main

import (
    "github.com/golang/protobuf/proto"
)

func main() {
    m := &M{}
    data := []byte("\v\x00")
    proto.Unmarshal(data, m)
}

Crashes with:

panic: reflect: call of reflect.Value.SetMapIndex on zero Value

goroutine 1 [running]:
runtime.gopanic(0x530860, 0xc2080104e0)
reflect.flag.mustBeExported(0x0)
reflect.Value.SetMapIndex(0x5058e0, 0xc208010440, 0xd5, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
github.com/golang/protobuf/proto.(*Buffer).dec_new_map(0xc208052f70, 0xc20806c480, 0xc208010440, 0x0, 0x0)
github.com/golang/protobuf/proto.(*Buffer).unmarshalType(0xc208052f70, 0x7f70a263e198, 0x5384e0, 0xc208048070, 0xc208010400, 0xc208010440, 0x0, 0x0)
github.com/golang/protobuf/proto.(*Buffer).Unmarshal(0xc208052f70, 0x7f70a263e2d8, 0xc208010440, 0x0, 0x0)
github.com/golang/protobuf/proto.UnmarshalMerge(0xc20800a570, 0x2, 0x8, 0x7f70a263e2d8, 0xc208010440, 0x0, 0x0)
github.com/golang/protobuf/proto.Unmarshal(0xc20800a570, 0x2, 0x8, 0x7f70a263e2d8, 0xc208010440, 0x0, 0x0)
main.main()