Skip to content
Snippets Groups Projects
Commit a88538d9 authored by Daniel Espinosa's avatar Daniel Espinosa
Browse files

XdParser: fix memory leaks for XDocument

parent 62de322b
Branches
Tags
No related merge requests found
......@@ -59,11 +59,9 @@ private class GXml.XdParser : GLib.Object, Parser {
public void read_element (GXml.DomElement element) throws GLib.Error {}
public void read_stream (GLib.InputStream stream) throws GLib.Error
{
var b = new MemoryOutputStream.resizable ();
b.splice (stream, 0);
if (b.data == null)
throw new ParserError.INVALID_STREAM_ERROR (_("stream doesn't provide data"));
read_string ((string) b.data);
GLib.DataInputStream b = new GLib.DataInputStream (stream);
string text = b.read_upto ("\0", -1, null);
read_string (text);
}
public async void read_stream_async (GLib.InputStream stream) throws GLib.Error
{
......@@ -74,7 +72,11 @@ private class GXml.XdParser : GLib.Object, Parser {
public void read_string (string str) throws GLib.Error
{
Xml.reset_last_error ();
document.doc = Xml.Parser.parse_memory (str, (int) str.length);
if (document.doc != null) {
delete document.doc;
}
document.doc = null;
document.doc = Xml.Parser.read_memory (str, str.length);
var e = Xml.get_last_error ();
if (e != null) {
var errmsg = _("Parser Error for string");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment