From 032ba5022655d1e66ddad3f568187bc46af66bd6 Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Mon, 15 Dec 2014 08:16:47 +0100 Subject: always free glib's GError structures * when throwing GlibError(), this is taken care of automatically. * fixes a memleak since there may be resources associated with the GError. --- src/error.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'src/error.h') 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 { -- cgit v1.2.3