The code you posted looks fine as far as I can tell, so I would guess that
there is some bug occurring earlier on that just happens to produce a crash
at this point. I would try running the code under Valgrind (or a similar
tool like ASan
<https://dev.chromium.org/developers/testing/addresssanitizer>) and see if
that reports any issues.

On Sat, Feb 11, 2017 at 3:01 AM, hce h <[email protected]> wrote:

> Hi,
>
> I have a following protocol and coded running on Debian Jessie in C++, I
> got google protobuf library malloc error at the statement of
> Device_Interface *interface = device->add_interface();, I could not find
> any errors in following implementation. Appreciate helps to fix the malloc
> error.
>
>     Device *device=hardware.add_device();
>     device->set_name(device_name)
>     device->set_devicetype(device_type);
>     for (auto local_interface = local_device.interfaces()) {
>         Device_Interface *interface = device->add_interface();  // Caused
> segmentation malloc error???
>         interface->set_name(local_interface.name());
>         ......
>     }
>
>
>
> message Hardware {
>     repeated Device device = 1;
> }
>
> message Device {
>     required string name = 1;
>     required string deviceType = 2;
>     repeated Interface interface = 3;
>
>     message Interface {
>          required string name = 1;
>          required string type = 2;
>     }
> }
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/protobuf.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to