From b3b15ff3b7e1d16681ef3c0d6cc88dd5e664695d Mon Sep 17 00:00:00 2001 From: Automerge script Date: Mon, 5 Nov 2012 22:25:47 +0000 Subject: [PATCH] Merged revisions 375863 via svnmerge from file:///srv/subversion/repos/asterisk/branches/10 ................ r375863 | rmudgett | 2012-11-05 15:39:00 -0600 (Mon, 05 Nov 2012) | 10 lines Add safety NULL pointer check in module user references. Made __ast_module_user_remove() check for NULL pointers. ........ Merged revision 375860 from C.3 ........ Merged revisions 375862 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ................ git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/10-digiumphones@375892 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- main/loader.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/main/loader.c b/main/loader.c index 0f8636bb93..9cbfaf7242 100644 --- a/main/loader.c +++ b/main/loader.c @@ -206,13 +206,14 @@ void ast_module_unregister(const struct ast_module_info *info) } } -struct ast_module_user *__ast_module_user_add(struct ast_module *mod, - struct ast_channel *chan) +struct ast_module_user *__ast_module_user_add(struct ast_module *mod, struct ast_channel *chan) { - struct ast_module_user *u = ast_calloc(1, sizeof(*u)); + struct ast_module_user *u; - if (!u) + u = ast_calloc(1, sizeof(*u)); + if (!u) { return NULL; + } u->chan = chan; @@ -229,6 +230,9 @@ struct ast_module_user *__ast_module_user_add(struct ast_module *mod, void __ast_module_user_remove(struct ast_module *mod, struct ast_module_user *u) { + if (!u) { + return; + } AST_LIST_LOCK(&mod->users); AST_LIST_REMOVE(&mod->users, u, entry); AST_LIST_UNLOCK(&mod->users); -- 2.47.2