mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-03 11:25:35 +00:00
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
This commit is contained in:
@@ -78,7 +78,7 @@ static int split_path(const char *path, char **dir, char **file)
|
||||
{
|
||||
RAII_VAR(char *, relative_dir, NULL, ast_free);
|
||||
RAII_VAR(char *, absolute_dir, NULL, ast_free);
|
||||
RAII_VAR(char *, real_dir, NULL, free);
|
||||
RAII_VAR(char *, real_dir, NULL, ast_std_free);
|
||||
char *last_slash;
|
||||
const char *file_portion;
|
||||
|
||||
@@ -108,7 +108,16 @@ static int split_path(const char *path, char **dir, char **file)
|
||||
return -1;
|
||||
}
|
||||
|
||||
#if defined(__AST_DEBUG_MALLOC)
|
||||
*dir = ast_strdup(real_dir); /* Dupe so we can ast_free() */
|
||||
#else
|
||||
/*
|
||||
* ast_std_free() and ast_free() are the same thing at this time
|
||||
* so we don't need to dupe.
|
||||
*/
|
||||
*dir = real_dir;
|
||||
real_dir = NULL;
|
||||
#endif /* defined(__AST_DEBUG_MALLOC) */
|
||||
*file = ast_strdup(file_portion);
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user