diff options
author | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2014-12-15 08:16:47 +0100 |
---|---|---|
committer | Robin Haberkorn <robin.haberkorn@googlemail.com> | 2014-12-15 08:16:47 +0100 |
commit | 032ba5022655d1e66ddad3f568187bc46af66bd6 (patch) | |
tree | 69ca4b2f5bcab6b161f73abd045e8740f1f39506 /src/error.h | |
parent | 1aab71ce61ea84cb15ed9a83ac4b2c5d22e92501 (diff) | |
download | sciteco-032ba5022655d1e66ddad3f568187bc46af66bd6.tar.gz |
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.
Diffstat (limited to 'src/error.h')
-rw-r--r-- | src/error.h | 12 |
1 files changed, 10 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 { |