From d2822e9faffdffc44ab6d8418c13b63a65e20338 Mon Sep 17 00:00:00 2001
From: Pino Toscano <ptoscano@redhat.com>
Date: Fri, 20 Jul 2018 14:08:50 +0200
Subject: [PATCH] * src/jmt.c (add_lens): fix memory leak w/ debugging
format_lens returns a new string every time, so save its result, and
free it properly after use.
(cherry picked from commit 4310fcc41c6f870da71d07423d6ac64ea6a60998)
---
src/jmt.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/src/jmt.c b/src/jmt.c
index 79953da1..86179eed 100644
--- a/src/jmt.c
+++ b/src/jmt.c
@@ -1109,16 +1109,20 @@ static ind_t add_lens(struct jmt *jmt, struct lens *lens) {
if (debugging("cf.jmt")) {
if (sA == NULL) {
+ char *s = format_lens(lens);
printf("add_lens: ");
print_regexp(stdout, lens->ctype);
- printf(" %s\n", format_lens(lens));
+ printf(" %s\n", s);
+ free(s);
} else {
+ char *s = format_lens(lens);
printf("add_lens: ");
flens(stdout, l);
- printf(" %u %s\n", sA->num, format_lens(lens));
+ printf(" %u %s\n", sA->num, s);
if (nullable) {
- printf("add_lens: // %s\n", format_lens(lens));
+ printf("add_lens: // %s\n", s);
}
+ free(s);
}
}
--
2.17.2