mirror of
https://github.com/asterisk/asterisk.git
synced 2025-11-16 23:08:32 +00:00
VECTOR: Passing parameters with side effects to macros is dangerous.
* Fix several instances where we were bumping a ref in the parameter and then unrefing the object if it failed. The way the AST_VECTOR_APPEND() and AST_VECTOR_REPLACE() macros are implemented means if it fails the new value was never evaluated. Change-Id: I2847872a455b11ea7e5b7ce697c0a455a1d0ac9a
This commit is contained in:
@@ -459,8 +459,9 @@ static struct message_subscription *get_or_create_subscription(struct ast_endpoi
|
||||
ao2_link(endpoint_subscriptions, sub);
|
||||
} else {
|
||||
ast_rwlock_wrlock(&tech_subscriptions_lock);
|
||||
if (AST_VECTOR_APPEND(&tech_subscriptions, ao2_bump(sub))) {
|
||||
/* Release the ao2_bump that was for the vector and allocation references. */
|
||||
ao2_ref(sub, +1);
|
||||
if (AST_VECTOR_APPEND(&tech_subscriptions, sub)) {
|
||||
/* Release the refs that were for the vector and the allocation. */
|
||||
ao2_ref(sub, -2);
|
||||
sub = NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user