From 1cfe56060ce3a386c03239396d51a93baa56895b Mon Sep 17 00:00:00 2001 From: Petteri Aimonen Date: Fri, 3 Apr 2015 21:07:14 +0300 Subject: [PATCH] Clear callbacks for union fields. Update issue 148 Status: FixedInGit --- pb_decode.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pb_decode.c b/pb_decode.c index 4d8c7cbe..b21bfe37 100644 --- a/pb_decode.c +++ b/pb_decode.c @@ -398,6 +398,9 @@ static bool checkreturn decode_static_field(pb_istream_t *stream, pb_wire_type_t *(pb_size_t*)iter->pSize = iter->pos->tag; if (PB_LTYPE(type) == PB_LTYPE_SUBMESSAGE) { + /* We memset to zero so that any callbacks are set to NULL. + * Then set any default values. */ + memset(iter->pData, 0, iter->pos->data_size); pb_message_set_to_defaults((const pb_field_t*)iter->pos->ptr, iter->pData); } return func(stream, iter->pos, iter->pData); -- 2.16.6