diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2016-01-28 02:34:41 +0100 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2016-01-28 02:45:18 +0100 |
commit | 0424327ba68803e98549b29e2115db334a6077d8 (patch) | |
tree | 41d965fddf7640bb7c2f2609f50bf8be84ffab88 /src/parser.cpp | |
parent | 40318a2ec0a513f23f301d22e5cd0ee7ac05f6eb (diff) | |
download | sciteco-0424327ba68803e98549b29e2115db334a6077d8.tar.gz |
fixed memory leaks in case of exceptions in StateExpectString
Diffstat (limited to 'src/parser.cpp')
-rw-r--r-- | src/parser.cpp | 17 |
1 files changed, 14 insertions, 3 deletions
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; } |