Check for ao2_alloc failure in __ast_channel_internal_alloc.
authorCorey Farrell <git@cfware.com>
Tue, 21 Apr 2015 20:17:33 +0000 (16:17 -0400)
committerCorey Farrell <git@cfware.com>
Tue, 21 Apr 2015 20:36:36 +0000 (15:36 -0500)
Fix a crash that could occur in __ast_channel_internal_alloc if
ao2_alloc fails.

ASTERISK-24991 #close

Change-Id: I4ca89189eb22f907408cb87d0a1645cfe1314a90

main/channel_internal_api.c

index a2fafbf..4e85398 100644 (file)
@@ -1449,6 +1449,10 @@ struct ast_channel *__ast_channel_internal_alloc(void (*destructor)(void *obj),
        tmp = ao2_alloc(sizeof(*tmp), destructor);
 #endif
 
+       if (!tmp) {
+               return NULL;
+       }
+
        if ((ast_string_field_init(tmp, 128))) {
                return ast_channel_unref(tmp);
        }