summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormihai.dontu@gmail.com <mihai.dontu@gmail.com>2013-01-06 07:07:02 +0200
committerThomas Graf <tgraf@suug.ch>2013-01-06 14:22:15 +0100
commitba38f3919835c39d7bc1e939ef3ca89cfe31600d (patch)
tree45bd54bdd2888ab9d750e7e4a1edad3cd83eaac4
parent00a5879e6e0b6b8f65730d77570780126c96c96a (diff)
downloadlibnl-ba38f3919835c39d7bc1e939ef3ca89cfe31600d.tar.gz
cache: make sure the user has specified a callback
In cache_include(), the user callback is used even though one might not have been specified, leading to a crash. This happens, for example, when NetworkManager calls nl_cache_include() with the change_cb argument set to NULL. Fix it by making sure the callback points to a valid address. Signed-off-by: Mihai Dontu <mihai.dontu@gmail.com> Signed-off-by: Thomas Graf <tgraf@suug.ch>
-rw-r--r--lib/cache.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/cache.c b/lib/cache.c
index 883aa51..42c0b5e 100644
--- a/lib/cache.c
+++ b/lib/cache.c
@@ -752,7 +752,8 @@ static int cache_include(struct nl_cache *cache, struct nl_object *obj,
* Handle them first.
*/
if (nl_object_update(old, obj) == 0) {
- cb(cache, old, NL_ACT_CHANGE, data);
+ if (cb)
+ cb(cache, old, NL_ACT_CHANGE, data);
nl_object_put(old);
return 0;
}