diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/error.h | 12 | ||||
-rw-r--r-- | src/main.cpp | 1 | ||||
-rw-r--r-- | src/spawn.cpp | 6 |
3 files changed, 17 insertions, 2 deletions
diff --git a/src/error.h b/src/error.h index 9029b86..3eb584c 100644 --- a/src/error.h +++ b/src/error.h @@ -147,8 +147,16 @@ public: class GlibError : public Error { public: - GlibError(const GError *gerror) - : Error("%s", gerror->message) {} + /** + * Construct error for glib's GError. + * Ownership of the error's resources is passed + * the GlibError object. + */ + GlibError(GError *gerror) + : Error("%s", gerror->message) + { + g_error_free(gerror); + } }; class SyntaxError : public Error { diff --git a/src/main.cpp b/src/main.cpp index 40b36cb..067e1b2 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -161,6 +161,7 @@ process_options(int &argc, char **&argv) if (!g_option_context_parse(options, &argc, &argv, &gerror)) { g_fprintf(stderr, "Option parsing failed: %s\n", gerror->message); + g_error_free(gerror); exit(EXIT_FAILURE); } diff --git a/src/spawn.cpp b/src/spawn.cpp index 7b7c10f..f5b7f2f 100644 --- a/src/spawn.cpp +++ b/src/spawn.cpp @@ -219,6 +219,8 @@ StateExecuteCommand::~StateExecuteCommand() { g_main_loop_unref(ctx.mainloop); g_main_context_unref(ctx.mainctx); + if (ctx.error) + g_error_free(ctx.error); } void @@ -414,6 +416,10 @@ gerror: else expressions.push(FAILURE); undo.push_var(register_argument) = NULL; + + g_error_free(ctx.error); + ctx.error = NULL; + return &States::start; } |