]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
core: Backport compatible MALLOC_DEBUG changes.
authorCorey Farrell <git@cfware.com>
Thu, 15 Mar 2018 09:49:49 +0000 (05:49 -0400)
committerCorey Farrell <git@cfware.com>
Thu, 15 Mar 2018 12:57:38 +0000 (06:57 -0600)
* Add support for MALLOC_DEBUG and DEBUG_CHAOS to be used together.
* Add utils/astmm.c to .gitignore.
* Fix MALLOC_DEBUG variant of __ast_vasprintf.  This function called
  va_end(ap) upon allocation failure.  This is incorrect since ap is
  passed as an argument.

Change-Id: I9f27ced4ce3cbe4b39547a67f994fdff491978c0

build_tools/cflags.xml
main/astmm.c
utils/.gitignore

index b4be282b8607b725cbaca5dab54206ed47f83431..34c65d70aba85113ea2b3036c2d3938c7c869424 100644 (file)
                        <support_level>extended</support_level>
                </member>
                <member name="MALLOC_DEBUG" displayname="Keep Track of Memory Allocations">
-                       <conflict>DEBUG_CHAOS</conflict>
                        <support_level>core</support_level>
                </member>
                <member name="DEBUG_CHAOS" displayname="Randomly FAIL memory allocations or other operations">
-                       <conflict>MALLOC_DEBUG</conflict>
                        <support_level>core</support_level>
                </member>
                <member name="ADDRESS_SANITIZER" displayname="Address Sanitizer">
index 59baa4221bb17985e48b93a31aee2463c2c7b413..2134a1f732a032a7be6925215d4c1a890c398306 100644 (file)
@@ -227,6 +227,8 @@ static void *__ast_alloc_region(size_t size, const enum func_type which, const c
        unsigned int *fence;
        int hash;
 
+       DEBUG_CHAOS_RETURN(DEBUG_CHAOS_ALLOC_CHANCE, NULL);
+
        if (!(reg = malloc(size + sizeof(*reg) + sizeof(*fence)))) {
                astmm_log("Memory Allocation Failure - '%d' bytes at %s %s() line %d\n",
                        (int) size, file, func, lineno);
@@ -664,7 +666,6 @@ int __ast_vasprintf(char **strp, const char *fmt, va_list ap, const char *file,
        size = vsnprintf(&s, 1, fmt, ap2);
        va_end(ap2);
        if (!(*strp = __ast_alloc_region(size + 1, FUNC_VASPRINTF, file, lineno, func, 0))) {
-               va_end(ap);
                return -1;
        }
        vsnprintf(*strp, size + 1, fmt, ap);
index 8e95c8df8fe2b33a24ca3b61ce9a4c496d8f0e39..f9ffe151da673d59019bd76410bbfe7923ad204c 100644 (file)
@@ -3,6 +3,7 @@ aelparse
 aelparse.c
 ast_expr2.c
 ast_expr2f.c
+astmm.c
 astman
 astcanary
 astdb2bdb