aboutsummaryrefslogtreecommitdiffstats
path: root/pb_decode.c
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@git.mail.kapsi.fi>2012-08-26 15:21:20 +0300
committerPetteri Aimonen <jpa@git.mail.kapsi.fi>2012-08-26 15:21:20 +0300
commita06dba6e49a7fc5fbc1e476539566e3f407be908 (patch)
tree5dd149d10ae2719339473c33f7124f612a59dbb7 /pb_decode.c
parent160f02e4d0f8f404492ffd4d7611ba4478190da2 (diff)
Fix warnings with -Wcast-qual. Add test for C++ compile.
Update issue 27 Status: FixedInGit
Diffstat (limited to 'pb_decode.c')
-rw-r--r--pb_decode.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/pb_decode.c b/pb_decode.c
index 601dc74..2235280 100644
--- a/pb_decode.c
+++ b/pb_decode.c
@@ -612,6 +612,7 @@ bool checkreturn pb_dec_submessage(pb_istream_t *stream, const pb_field_t *field
{
bool status;
pb_istream_t substream;
+ const pb_field_t* submsg_fields = (const pb_field_t*)field->ptr;
if (!pb_make_string_substream(stream, &substream))
return false;
@@ -619,7 +620,13 @@ bool checkreturn pb_dec_submessage(pb_istream_t *stream, const pb_field_t *field
if (field->ptr == NULL)
PB_RETURN_ERROR(stream, "invalid field descriptor");
- status = pb_decode_noinit(&substream, (pb_field_t*)field->ptr, dest);
+ /* New array entries need to be initialized, while required and optional
+ * submessages have already been initialized in the top-level pb_decode. */
+ if (PB_HTYPE(field->type) == PB_HTYPE_ARRAY)
+ status = pb_decode(&substream, submsg_fields, dest);
+ else
+ status = pb_decode_noinit(&substream, submsg_fields, dest);
+
pb_close_string_substream(stream, &substream);
return status;
}