summaryrefslogtreecommitdiffstats
path: root/pb_common.c
AgeCommit message (Collapse)AuthorFilesLines
2016-12-31Fix multiple oneofs in same message (issue #229)Petteri Aimonen1-3/+3
Previously the field iterator logic didn't know whether two oneof fields were part of the same union, or separate. This caused wrong pointers to be calculated if multiple oneofs were inside a single message. This commit fixes this by using dataoffset of PB_SIZE_MAX to indicate union fields after the first field. Theoretically PB_SIZE_MAX is also a valid value for data offset, which could cause errors. Adding a compile-time assert for this is somewhat difficult. However I consider it extremely unlikely that there is any platform that could trigger this situation, as it would require 255 bytes of extra data/padding between two protobuf oneof fields. On 64-bit architectures the worst case is 16 bytes, and even esoteric platforms only align to 64 bytes or so. Manual modification of the generated .pb.h file could trigger this, but even then it would require pretty bad luck to happen.
2015-01-11Bugfixes for oneof support.Petteri Aimonen1-10/+10
Fixes crashes / memory leaks when using pointer type fields. Also fixes initialization of which_oneof fields.
2015-01-04Implement support for oneofs (C unions).Petteri Aimonen1-0/+7
Basic test included, should probably add an oneof to the AllTypes test also. Update issue 131 Status: Started
2014-08-10Switch pb_encode to use the common iterator logic in pb_common.cPetteri Aimonen1-2/+4
Update issue 128 Status: FixedInGit
2014-08-10Separate field iterator logic from pb_decode to pb_common.Petteri Aimonen1-0/+88