mlot / nanopb

Automatically exported from code.google.com/p/nanopb
zlib License
0 stars 0 forks source link

repeated string callback not invoked for empty strings #73

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Prepare a message with a repeated string field.
2. Store at least one empty string in the repeated string field.
3. Setup a callback for the repeated string field.
4. Decode the message.

What is the expected output? What do you see instead?
Expected: Callback called for all strings in the repeated string field.
Actual: Callback only called for non-empty strings in the repeated string field.

What version of the product are you using? On what operating system?
Reproduced in all version between "0.1.7" and "0.2.0".

Please provide any additional information below.

Empty strings are not irrelevant and needs to be visible for applications.

Suggested fix:

In function decode_callback_field replace the code:
while (substream.bytes_left)
{
    if (!pCallback->funcs.decode(&substream, iter->current, pCallback->arg))
        PB_RETURN_ERROR(stream, "callback failed");
}

with the following code:
do
{
    if (!pCallback->funcs.decode(&substream, iter->current, pCallback->arg))
        PB_RETURN_ERROR(stream, "callback failed");
}
while (substream.bytes_left);

To allow correct handling of empty string on application level.

Original issue reported on code.google.com by henrik.c...@gmail.com on 13 Apr 2013 at 11:09

GoogleCodeExporter commented 9 years ago

Original comment by Petteri.Aimonen on 13 Apr 2013 at 5:04

GoogleCodeExporter commented 9 years ago
This issue was updated by revision 9939910833a9.

Original comment by Petteri.Aimonen on 14 Apr 2013 at 6:50

GoogleCodeExporter commented 9 years ago
Fix released in 0.2.1

Original comment by Petteri.Aimonen on 14 Apr 2013 at 7:19