From: Corey Farrell Date: Thu, 15 Mar 2018 09:49:49 +0000 (-0400) Subject: core: Backport compatible MALLOC_DEBUG changes. X-Git-Tag: 15.4.0-rc1~66^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5be16ef66ee1f19aad48b7212d41045b7c89ad43;p=thirdparty%2Fasterisk.git core: Backport compatible MALLOC_DEBUG changes. * 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 --- diff --git a/build_tools/cflags.xml b/build_tools/cflags.xml index f05f42869f..c4f9458ec6 100644 --- a/build_tools/cflags.xml +++ b/build_tools/cflags.xml @@ -78,11 +78,9 @@ extended - DEBUG_CHAOS core - MALLOC_DEBUG core diff --git a/main/astmm.c b/main/astmm.c index accd2ffcf7..3a07f3996d 100644 --- a/main/astmm.c +++ b/main/astmm.c @@ -216,6 +216,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); @@ -653,7 +655,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); diff --git a/utils/.gitignore b/utils/.gitignore index dbdc6b6d21..7840265e5e 100644 --- a/utils/.gitignore +++ b/utils/.gitignore @@ -3,6 +3,7 @@ aelparse aelparse.c ast_expr2.c ast_expr2f.c +astmm.c astman astcanary astdb2bdb