summaryrefslogtreecommitdiff
path: root/src/context.c
diff options
context:
space:
mode:
authorRan Benita <ran234@gmail.com>2012-10-29 01:00:27 +0200
committerRan Benita <ran234@gmail.com>2012-10-29 01:20:04 +0200
commit7261f404d201b157dc0ce1ae0386fd74f3a128a7 (patch)
treefbd0cf78ce7ace10dc1f79042163be0ab0b3528a /src/context.c
parenta51ee70419cf492a46020123294c7f708c81070d (diff)
downloadxorg-lib-libxkbcommon-7261f404d201b157dc0ce1ae0386fd74f3a128a7.tar.gz
state, context: allow passing NULL to *_unref()
For error handling code, it's nice to be able to pass NULL to these function without worrying about segfaults ensuing. free() sets the precedent here. Also document this fact. Signed-off-by: Ran Benita <ran234@gmail.com>
Diffstat (limited to 'src/context.c')
-rw-r--r--src/context.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/context.c b/src/context.c
index 53028a1..a846b8f 100644
--- a/src/context.c
+++ b/src/context.c
@@ -206,7 +206,7 @@ xkb_context_ref(struct xkb_context *ctx)
XKB_EXPORT void
xkb_context_unref(struct xkb_context *ctx)
{
- if (--ctx->refcnt > 0)
+ if (!ctx || --ctx->refcnt > 0)
return;
xkb_context_include_path_clear(ctx);