Don't unref user twice on failure. Also, when adding sorted list of users, it is best to check the entry already in the list for a "next" entry instead of the newly created entry...

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@114124 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Terry Wilson
2008-04-14 19:12:27 +00:00
parent 6e6d6f2e10
commit 6d34b5fafe

View File

@@ -866,9 +866,8 @@ static int add_user_extension(struct user *user, struct extension *exten)
AST_LIST_INSERT_BEFORE_CURRENT(exten, entry); AST_LIST_INSERT_BEFORE_CURRENT(exten, entry);
} else if (exten->index == exten_iter->index) { } else if (exten->index == exten_iter->index) {
ast_log(LOG_WARNING, "Duplicate linenumber=%d for %s\n", exten->index, user->macaddress); ast_log(LOG_WARNING, "Duplicate linenumber=%d for %s\n", exten->index, user->macaddress);
user = unref_user(user); /* Profile should be unreffed now that it is attached to the user */
return -1; return -1;
} else if (!AST_LIST_NEXT(exten, entry)) { } else if (!AST_LIST_NEXT(exten_iter, entry)) {
AST_LIST_INSERT_TAIL(&user->extensions, exten, entry); AST_LIST_INSERT_TAIL(&user->extensions, exten, entry);
} }
} }