Commit e6b5ff0
Report error if malloc fails
Changed files (2)
Diff
@@ -69,11 +69,10 @@ internal const int WARNINGS = 1; * */ public class XmlParser : GLib.Object {- public Tag root;- public XmlData data;- public string input;- public bool error;- public int refcount = 1;+ Tag root;+ XmlData data;+ string input;+ bool error; /** * Create a new xml parser. @@ -81,7 +80,7 @@ public class XmlParser : GLib.Object { */ public XmlParser (string data) { this.input = data;- this.data = new XmlData (data, data.length);+ this.data = new XmlData (data, data.length); reparse (NONE); } @@ -90,6 +89,11 @@ public class XmlParser : GLib.Object { * @return true if the xml document is valid xml. */ public bool validate () {+ if (this.data.error) {+ error = true;+ return false;+ } + reparse (NONE); if (error) {@@ -19,6 +19,8 @@ public class XmlData : XmlString { int tags_capacity; int tags_size; + internal bool error = false;+ public XmlData (char* data, int length) { base (data, length); @@ -92,8 +94,8 @@ public class XmlData : XmlString { bool increase_capacity () { int* tags; - tags_capacity += 10;- tags = (int*) new int [tags_capacity];+ tags_capacity += 512;+ tags = (int*) try_malloc (tags_capacity * sizeof (int)); if (tags == null) { tags_capacity = 0;@@ -101,6 +103,8 @@ public class XmlData : XmlString { if (start_tags != null) { delete start_tags; start_tags = null;+ tags_size = 0;+ error = true; } warning ("Can not allocate xml data buffer.");