[1/6] scanner: Plug two memory leaks

Submitted by Daniel Stone on Aug. 29, 2018, 6:17 a.m.

Details

Message ID 20180829061715.27776-2-daniels@collabora.com
State Accepted
Commit a2ed67e85c386413979ab30bf5ec48dc19fcf99e
Headers show
Series "Minor test/scanner fixes" ( rev: 1 ) in Wayland (DEPRECATED)

Browsing this patch as part of:
"Minor test/scanner fixes" rev 1 in Wayland (DEPRECATED)
<< prev patch [1/6] next patch >>

Commit Message

Daniel Stone Aug. 29, 2018, 6:17 a.m.
Found with both ASan leak sanitizer and Valgrind. We were trivially
leaking the enum name for every arg parsed by the scanner which had one.
If libxml-based DTD validation was enabled, we would also leak the DTD
itself, despite diligently freeing the document, context, etc.

Signed-off-by: Daniel Stone <daniels@collabora.com>
---
 src/scanner.c | 2 ++
 1 file changed, 2 insertions(+)

Patch hide | download patch | download mbox

diff --git a/src/scanner.c b/src/scanner.c
index 205c28a9..3afc3d3d 100644
--- a/src/scanner.c
+++ b/src/scanner.c
@@ -133,6 +133,7 @@  is_dtd_valid(FILE *input, const char *filename)
 	rc = xmlValidateDtd(dtdctx, doc, dtd);
 	xmlFreeDoc(doc);
 	xmlFreeParserCtxt(ctx);
+	xmlFreeDtd(dtd);
 	xmlFreeValidCtxt(dtdctx);
 	/* xmlIOParseDTD consumes buffer */
 
@@ -432,6 +433,7 @@  free_arg(struct arg *arg)
 	free(arg->name);
 	free(arg->interface_name);
 	free(arg->summary);
+	free(arg->enumeration_name);
 	free(arg);
 }