aboutsummaryrefslogtreecommitdiffstats
path: root/pb_encode.c
diff options
context:
space:
mode:
authorPetteri Aimonen <jpa@npb.mail.kapsi.fi>2011-12-30 08:43:50 +0000
committerPetteri Aimonen <jpa@npb.mail.kapsi.fi>2011-12-30 08:43:50 +0000
commit1506450b119a504259983692cca4c8cd3daddaf1 (patch)
tree33e9d13dac92904942c9d822148a5173b0542673 /pb_encode.c
parentad7a0e2111aaf599466153097e4c8eebf476244d (diff)
Fixed a bug related to submessage encoding into memory buffer.
Stream state was not copied back from substream in pb_enc_submessage, which caused garbage output if the stream callback modified the state. Expanded tests to cover this problem. Thanks to Paweł Pery for debugging and reporting this problem. git-svn-id: https://svn.kapsi.fi/jpa/nanopb@1089 e3a754e5-d11d-0410-8d38-ebb782a927b9
Diffstat (limited to 'pb_encode.c')
-rw-r--r--pb_encode.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/pb_encode.c b/pb_encode.c
index 317e31ef..995eb3de 100644
--- a/pb_encode.c
+++ b/pb_encode.c
@@ -376,6 +376,7 @@ bool checkreturn pb_enc_submessage(pb_ostream_t *stream, const pb_field_t *field
status = pb_encode(&substream, (pb_field_t*)field->ptr, src);
stream->bytes_written += substream.bytes_written;
+ stream->state = substream.state;
if (substream.bytes_written != size)
return false;