[Asterisk-code-review] stasis message.c: Don't create immutable stasis objects with... (asterisk[15])

George Joseph asteriskteam at digium.com
Wed Sep 19 08:04:08 CDT 2018


George Joseph has submitted this change and it was merged. ( https://gerrit.asterisk.org/10186 )

Change subject: stasis_message.c: Don't create immutable stasis objects with locks.
......................................................................

stasis_message.c: Don't create immutable stasis objects with locks.

* Create the stasis message object without a lock as it is immutable.
* Create the stasis message type object without a lock as it is immutable.
* Creating the stasis message type could crash if the passed in type name
is NULL and REF_DEBUG is enabled.  Added missing NULL check when passing
the ao2 object tag string.

Change-Id: I28763c58bb9f0b427c11971d0103bf94055e7b32
---
M main/stasis_message.c
1 file changed, 4 insertions(+), 2 deletions(-)

Approvals:
  Corey Farrell: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved; Approved for Submit



diff --git a/main/stasis_message.c b/main/stasis_message.c
index 482dd01..49d6c05 100644
--- a/main/stasis_message.c
+++ b/main/stasis_message.c
@@ -61,7 +61,8 @@
 		return STASIS_MESSAGE_TYPE_DECLINED;
 	}
 
-	type = ao2_t_alloc(sizeof(*type), message_type_dtor, name);
+	type = ao2_t_alloc_options(sizeof(*type), message_type_dtor,
+		AO2_ALLOC_OPT_LOCK_NOLOCK, name ?: "");
 	if (!type) {
 		return STASIS_MESSAGE_TYPE_ERROR;
 	}
@@ -121,7 +122,8 @@
 		return NULL;
 	}
 
-	message = ao2_t_alloc(sizeof(*message), stasis_message_dtor, type->name);
+	message = ao2_t_alloc_options(sizeof(*message), stasis_message_dtor,
+		AO2_ALLOC_OPT_LOCK_NOLOCK, type->name);
 	if (message == NULL) {
 		return NULL;
 	}

-- 
To view, visit https://gerrit.asterisk.org/10186
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 15
Gerrit-MessageType: merged
Gerrit-Change-Id: I28763c58bb9f0b427c11971d0103bf94055e7b32
Gerrit-Change-Number: 10186
Gerrit-PatchSet: 3
Gerrit-Owner: Richard Mudgett <rmudgett at digium.com>
Gerrit-Reviewer: Corey Farrell <git at cfware.com>
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Sean Bright <sean.bright at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180919/b7ba5425/attachment.html>


More information about the asterisk-code-review mailing list