summaryrefslogtreecommitdiff
path: root/main/utils.c
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2013-10-02 17:12:49 +0000
committerRichard Mudgett <rmudgett@digium.com>2013-10-02 17:12:49 +0000
commit97fcd6366d128a8b9b176783743d66dbfab6e615 (patch)
treeb70dfad6f2433b9b6a7cc7ee7455ab1585c66072 /main/utils.c
parentd14869bcadf719564436b252958a0a2a3ea27fd4 (diff)
MALLOC_DEBUG: Fix some misuses of free() when MALLOC_DEBUG is enabled.
* There were several places in ARI where an external library was mallocing memory that must always be released with free(). When MALLOC_DEBUG is enabled, free() is redirected to the MALLOC_DEBUG version. Since the external library call still uses the normal malloc(), MALLOC_DEBUG complains that the freed memory block is not registered and will not free it. These cases must use ast_std_free(). * Changed calls to asprintf() and vasprintf() to the equivalent ast_asprintf() and ast_vasprintf() versions respectively. ........ Merged revisions 400270 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@400271 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/utils.c')
-rw-r--r--main/utils.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/main/utils.c b/main/utils.c
index e2c5e2c3f..6eebff71a 100644
--- a/main/utils.c
+++ b/main/utils.c
@@ -656,9 +656,10 @@ static void lock_info_destroy(void *data)
}
pthread_mutex_destroy(&lock_info->lock);
- if (lock_info->thread_name)
- free((void *) lock_info->thread_name);
- free(lock_info);
+ if (lock_info->thread_name) {
+ ast_free((void *) lock_info->thread_name);
+ }
+ ast_free(lock_info);
}
/*!
@@ -2184,7 +2185,7 @@ int ast_mkdir(const char *path, int mode)
static int safe_mkdir(const char *base_path, char *path, int mode)
{
- RAII_VAR(char *, absolute_path, NULL, free);
+ RAII_VAR(char *, absolute_path, NULL, ast_std_free);
absolute_path = realpath(path, NULL);
@@ -2206,7 +2207,7 @@ static int safe_mkdir(const char *base_path, char *path, int mode)
int res;
while (path_term) {
- RAII_VAR(char *, absolute_subpath, NULL, free);
+ RAII_VAR(char *, absolute_subpath, NULL, ast_std_free);
/* Truncate the path one past the slash */
char c = *(path_term + 1);
@@ -2254,7 +2255,7 @@ static int safe_mkdir(const char *base_path, char *path, int mode)
int ast_safe_mkdir(const char *base_path, const char *path, int mode)
{
- RAII_VAR(char *, absolute_base_path, NULL, free);
+ RAII_VAR(char *, absolute_base_path, NULL, ast_std_free);
RAII_VAR(char *, p, NULL, ast_free);
if (base_path == NULL || path == NULL) {