Opened 12 years ago

Closed 12 years ago

#4245 closed Bugs (fixed)

encode_char_entities does not handle empty string properly (affects write_graphml)

Reported by: Christopher Alfeld <alfeld@…> Owned by: Sebastian Redl
Milestone: Boost 1.43.0 Component: property_tree
Version: Boost 1.44.0 Severity: Problem
Keywords: graph, write_graphml, xml Cc: alfeld@…

Description

The write_graphml function uses encode_char_entities from the property_tree::xml_parser. This latter function does not behave properly when passed an empty string.

I fixed this by modifying encode_char_entities to work properly in the empty string case. I found this preferable to patching write_graphml to be aware of the limitation of encode_char_entities.

Attached is a sample program that crashes on my system (Snow Leopard), the output and stack trace of that crash, and a patch to trunk r62110 which fixes the issue.

Attachments (4)

demo.cpp (493 bytes ) - added by Christopher Alfeld <alfeld@…> 12 years ago.
Program to demonstrate problems -- throws std::length_error.
output.txt (561 bytes ) - added by Christopher Alfeld <alfeld@…> 12 years ago.
Output of program.
stacktrace.txt (988 bytes ) - added by Christopher Alfeld <alfeld@…> 12 years ago.
Stack trace of program.
boost_xml.patch (626 bytes ) - added by Christopher Alfeld <alfeld@…> 12 years ago.
Patch for r62110 trunk.

Download all attachments as: .zip

Change History (6)

by Christopher Alfeld <alfeld@…>, 12 years ago

Attachment: demo.cpp added

Program to demonstrate problems -- throws std::length_error.

by Christopher Alfeld <alfeld@…>, 12 years ago

Attachment: output.txt added

Output of program.

by Christopher Alfeld <alfeld@…>, 12 years ago

Attachment: stacktrace.txt added

Stack trace of program.

by Christopher Alfeld <alfeld@…>, 12 years ago

Attachment: boost_xml.patch added

Patch for r62110 trunk.

comment:1 by Christopher Alfeld <alfeld@…>, 12 years ago

Cc: alfeld@… added

comment:2 by Sebastian Redl, 12 years ago

Resolution: fixed
Status: newclosed

(In [62195]) Make encode_char_entities safe against empty strings, because Graph uses it that way. Fixes bug 4245. Based on patch by Christopher Alfeld.

Note: See TracTickets for help on using tickets.