GNOME Bugzilla – Bug 789053
xml: Don't crash parsing empty XML string
Last modified: 2017-10-18 06:59:51 UTC
Calling rest_xml_parser_parse_from_data() with an empty string ("") currently causes a crash as xmlReaderForMemory() returns NULL in that case, and we then try to dereference this pointer without checking it's non-NULL.
Created attachment 361668 [details] [review] xml: Don't crash parsing empty XML string
Review of attachment 361668 [details] [review]: I am not a librest developer, but it looks good to me. ::: tests/xml.c @@ +36,3 @@ + root = rest_xml_parser_parse_from_data (parser, "", -1); + g_assert (root == NULL); I wonder if we should switch to g_assert_null and friends in future. @@ +38,3 @@ + g_assert (root == NULL); + root = rest_xml_parser_parse_from_data (parser, "<invalid", -1); + g_assert (root == NULL); Nitpick: maybe a newline after this for aesthetics?
Attachment 361668 [details] pushed as a217a9f - xml: Don't crash parsing empty XML string