Skip to content

Fix random dropping of characters on dumping ASCII encoded XML

Mohammad Razavi requested to merge admirito/libxml2:fix-radnom-drop into master

Fix a bug in xmlCharEncOutput return value which will cause xmlNodeDumpOutput to drop characters randomly.

xmlCharEncOutput returns zero if the length of the input buffer is zero but ignores the fact that it may already encoded the input buffer and the input's length is zero due to the fact that xmlEncOutputChunk returned -2 errors and underlying code tries to fix the error by encoding the input.

xmlCharEncOutput is collecting the number of bytes written to the output buffer but is returning zero instead of the total number of bytes in this situation. This commit will fix this issue by returning the total number of bytes instead. So the xmlNodeDumpOutput will also continue writing and will not stop due to the fact that it mistakenly thinks the output buffer is not changed in that iteration.

Fixes #314 (closed)

Merge request reports