[PATCH 04/10] Fix memory leak in srcpos_verror()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Since dtc runs are short, we don't care that much about memory leaks.
Still, leaking the source position string every time we print an error
messages is pretty nasty.  Fix it.

Signed-off-by: David Gibson <david@xxxxxxxxxxxxxxxxxxxxx>
---
 srcpos.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/srcpos.c b/srcpos.c
index 48059aa..6705fed 100644
--- a/srcpos.c
+++ b/srcpos.c
@@ -293,13 +293,15 @@ srcpos_string(struct srcpos *pos)
 void
 srcpos_verror(struct srcpos *pos, const char *fmt, va_list va)
 {
-	const char *srcstr;
+	char *srcstr;
 
 	srcstr = srcpos_string(pos);
 
 	fprintf(stderr, "Error: %s ", srcstr);
 	vfprintf(stderr, fmt, va);
 	fprintf(stderr, "\n");
+
+	free(srcstr);
 }
 
 void
-- 
1.8.4.2

--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]
  Powered by Linux