diff options
author | Dan Winship <danw@gnome.org> | 2012-04-23 11:02:48 -0400 |
---|---|---|
committer | Dan Winship <danw@gnome.org> | 2012-04-23 16:09:58 -0400 |
commit | be18dd06cd138be232ff68ec7af19cfcf2f969ed (patch) | |
tree | 79142d51b6ada6abde403cdb3095d6e4558cad6f /include | |
parent | 411cb363444177369e55e98d613ae35ae7bddd81 (diff) | |
download | NetworkManager-be18dd06cd138be232ff68ec7af19cfcf2f969ed.tar.gz |
libnm-glib: NULL out priv fields on dispose()
In some situations, objects might get used after being disposed, so
clear out their various priv fields so we don't try to access unreffed
objects, freed strings, etc.
https://bugzilla.gnome.org/show_bug.cgi?id=674473
Diffstat (limited to 'include')
-rw-r--r-- | include/nm-glib-compat.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/include/nm-glib-compat.h b/include/nm-glib-compat.h index 30b83e0d55..e953f6ebcd 100644 --- a/include/nm-glib-compat.h +++ b/include/nm-glib-compat.h @@ -42,6 +42,16 @@ g_simple_async_result_set_from_error (result, __error); \ g_error_free (__error); \ } G_STMT_END + +#define g_clear_object(object_ptr) \ + G_STMT_START { \ + GObject **__obj_p = object_ptr; \ + if (*__obj_p) { \ + g_object_unref (*__obj_p); \ + *__obj_p = NULL; \ + } \ + } G_STMT_END + #endif #endif /* NM_GLIB_COMPAT_H */ |