[PATCH 05/10] lib: fwts_formatting: fix memory leak
Colin King
colin.king at canonical.com
Thu May 1 14:01:16 UTC 2014
From: Colin Ian King <colin.king at canonical.com>
Coverity Scan detected a memory leak with tidied_text
on the NULL return path, so free this before we return.
Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
src/lib/src/fwts_formatting.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/lib/src/fwts_formatting.c b/src/lib/src/fwts_formatting.c
index ffc9601..555722e 100644
--- a/src/lib/src/fwts_formatting.c
+++ b/src/lib/src/fwts_formatting.c
@@ -117,6 +117,7 @@ fwts_list *fwts_format_text(const char *text, const int width)
if (lastspace != NULL) {
if ((tmp = dup_line(linestart, lastspace, width)) == NULL) {
fwts_text_list_free(list);
+ free(tidied_text);
return NULL;
}
fwts_text_list_append(list, tmp);
@@ -132,6 +133,7 @@ fwts_list *fwts_format_text(const char *text, const int width)
}
if ((tmp = dup_line(linestart, textptr, width)) == NULL) {
fwts_text_list_free(list);
+ free(tidied_text);
return NULL;
}
fwts_text_list_append(list, tmp);
--
2.0.0.rc0
More information about the fwts-devel
mailing list