From 0424327ba68803e98549b29e2115db334a6077d8 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Thu, 28 Jan 2016 02:34:41 +0100 Subject: fixed memory leaks in case of exceptions in StateExpectString --- src/parser.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/parser.cpp b/src/parser.cpp index 88c4350..98eeba8 100644 --- a/src/parser.cpp +++ b/src/parser.cpp @@ -478,8 +478,13 @@ StateExpectString::custom(gchar chr) if (string_building) machine.reset(); - /* FIXME: possible memleak because of `string`? */ - next = done(string ? : ""); + try { + next = done(string ? : ""); + } catch (...) { + g_free(string); + throw; + } + g_free(string); return next; } @@ -502,7 +507,13 @@ StateExpectString::custom(gchar chr) undo.push_str(strings[0]); String::append(strings[0], insert); - process(strings[0], strlen(insert)); + try { + process(strings[0], strlen(insert)); + } catch (...) { + g_free(insert); + throw; + } + g_free(insert); return this; } -- cgit v1.2.3