Rapid XML 1.12 doesn't handle zero-length strings correctly
Brought to you by:
kaalus
Rapid XML 1.12 interprets a zero, when specified as a string's length, as indicating that the string is a C-string & its length should be calculated appropriately.
This makes it difficult to add variable length data where it may have zero length, but isn't necessarily a C-string. This may have also introduced hidden bugs into users code. Zero is a valid length for data & should be interpreted literally.
The attached patch defines a new constant `auto_size` to use instead of `0` and modifies code appropriately. Note: The change was sufficient for my usage. It probably requires some further work to update every occurrence.
Initial patch to handle zero-length strings
This is a significant problem. Take, for instance, a routine which is designed to copy an arbitrary XML tree to a different document. To support both destructively-parsed and non-destructively-parsed trees, and for efficiency, such a routine will need to call allocate_string() with a length parameter. But if the source tree contains strings with zero length that are not NULL terminated, all hell will break loose.