Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upThe "fetch" method uses wrong indexing for repeated messages/groups #62
Comments
|
Good analysis, this looks "likely" also based on the lines above it all using |
|
Thanks again for the report, and suggested fix. The new version is now on CRAN. Next time we can do a proper pull request so that you get proper credit (but we'd still prefer an identifiable name and email with that....) |
I have tested the below example with RProtobuf 0.4.9 on R version 3.4.1 (x86_64-pc-linux-gnu).
The fetch method disregards the provided index for repeated message types:
I believe the issue is with the
get_field_valuescode in wrapper_Message.cpp. The code uses raw loop variableiinstead ofindex[i]for repeated messages and groups:res[i] = S4_Message(CLONE(&ref->GetRepeatedMessage(*message, field_desc, i)));Hence the fix should be trivial:
res[i] = S4_Message(CLONE(&ref->GetRepeatedMessage(*message, field_desc, index[i])));Please also note that a reasonable workaround for this issue is to iterate through the repeated messages without using the fetch method: