Merged revisions 149199 via svnmerge from

https://origsvn.digium.com/svn/asterisk/trunk

........
  r149199 | tilghman | 2008-10-14 17:38:06 -0500 (Tue, 14 Oct 2008) | 8 lines
  
  Add additional memory debugging to several core APIs, and fix several memory
  leaks found with these changes.
  (Closes issue #13505, closes issue #13543)
  Reported by: mav3rick, triccyx
   Patches: 
         20081001__bug13505.diff.txt uploaded by Corydon76 (license 14)
   Tested by: mav3rick, triccyx
........


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.1@149202 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Tilghman Lesher
2008-10-14 22:42:17 +00:00
parent 0fa430ed59
commit e65c411c8f
10 changed files with 119 additions and 7 deletions

View File

@@ -230,14 +230,22 @@ struct ast_config_include {
struct ast_config_include *next; /*!< ptr to next inclusion in the list */
};
#ifdef MALLOC_DEBUG
struct ast_variable *_ast_variable_new(const char *name, const char *value, const char *filename, const char *file, const char *func, int lineno)
#else
struct ast_variable *ast_variable_new(const char *name, const char *value, const char *filename)
#endif
{
struct ast_variable *variable;
int name_len = strlen(name) + 1;
int val_len = strlen(value) + 1;
int fn_len = strlen(filename) + 1;
#ifdef MALLOC_DEBUG
if ((variable = __ast_calloc(1, name_len + val_len + fn_len + sizeof(*variable), file, lineno, func))) {
#else
if ((variable = ast_calloc(1, name_len + val_len + fn_len + sizeof(*variable)))) {
#endif
char *dst = variable->stuff; /* writable space starts here */
variable->name = strcpy(dst, name);
dst += name_len;