From e9fb7da04057e108c4d9e5461d1679dfd86b34d2 Mon Sep 17 00:00:00 2001 From: delphij Date: Mon, 14 Sep 2015 18:05:27 +0000 Subject: MFC r287247: Plug memory leaks when running out of memory. Reported by: clang scan-build --- lib/libgeom/geom_xml2tree.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/libgeom/geom_xml2tree.c') diff --git a/lib/libgeom/geom_xml2tree.c b/lib/libgeom/geom_xml2tree.c index 54a31ca..2a373d7 100644 --- a/lib/libgeom/geom_xml2tree.c +++ b/lib/libgeom/geom_xml2tree.c @@ -275,15 +275,17 @@ EndElement(void *userData, const char *name) XML_StopParser(mt->parser, 0); warn("Cannot allocate memory during processing of '%s' " "element", name); + free(p); return; } gc->lg_name = strdup(name); if (gc->lg_name == NULL) { - free(gc); mt->error = errno; XML_StopParser(mt->parser, 0); warn("Cannot allocate memory during processing of '%s' " "element", name); + free(gc); + free(p); return; } gc->lg_val = p; -- cgit v1.1