[PATCH wayland 1/6] scanner: Plug two memory leaks

Daniel Stone daniels at collabora.com
Wed Aug 29 06:17:10 UTC 2018


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 at collabora.com>
---
 src/scanner.c | 2 ++
 1 file changed, 2 insertions(+)

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);
 }
 
-- 
2.17.1



More information about the wayland-devel mailing list