]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Make sure to set owner_line, ownder_func, and owner_file in ast_calloc_with_stringfields.
authorMark Michelson <mmichelson@digium.com>
Fri, 15 Jan 2010 20:58:24 +0000 (20:58 +0000)
committerMark Michelson <mmichelson@digium.com>
Fri, 15 Jan 2010 20:58:24 +0000 (20:58 +0000)
Asterisk would crash on startup if MALLOC_DEBUG were set in menuselect. This is because
the manager action UpdateConfig had to resize its string field allocation to set the
description. When the resize occurred, ast_copy_string would crash because we were
attempting to copy a string from a NULL pointer. Setting the strings initially makes
the code much less crashy.

git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@240420 65c4cc65-6c06-0410-ace0-fbb531ad65f3

main/utils.c

index e900f7be25e2b4cce3585e43661ac84400ed1927..86dcb042843bfcb4fbc1c27a0ead8ffe52d7b76c 100644 (file)
@@ -1792,6 +1792,11 @@ void *__ast_calloc_with_stringfields(unsigned int num_structs, size_t struct_siz
                mgr->embedded_pool = pool;
                *pool_head = pool;
                pool->size = size_to_alloc - struct_size - sizeof(*pool);
+#if defined(__AST_DEBUG_MALLOC)
+               mgr->owner_file = file;
+               mgr->owner_func = func;
+               mgr->owner_line = lineno;
+#endif
        }
 
        return allocation;