[asterisk-commits] tilghman: trunk r194101 - in /trunk/main: logger.c pbx.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue May 12 19:13:54 CDT 2009
Author: tilghman
Date: Tue May 12 19:13:43 2009
New Revision: 194101
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=194101
Log:
Two fixes found while debugging with ast_backtrace():
1) If MALLOC_DEBUG is used when concurrently using ast_backtrace, the free()
used in that routine will trigger an error, because the memory was allocated
internally to libc, where we could not intercept that call to wrap it.
Therefore, it's not memory we knew about, and the free is reported as an
error.
2) Now that channels are objects, the old hack of initializing a channel
to all zeroes no longer works, since we may try to call something like
ast_channel_lock() within a function on that reference. In that case, it's
reported as an error, because the pointer isn't an object reference.
Modified:
trunk/main/logger.c
trunk/main/pbx.c
Modified: trunk/main/logger.c
URL: http://svn.asterisk.org/svn-view/asterisk/trunk/main/logger.c?view=diff&rev=194101&r1=194100&r2=194101
==============================================================================
--- trunk/main/logger.c (original)
+++ trunk/main/logger.c Tue May 12 19:13:43 2009
@@ -1159,6 +1159,9 @@
for (i = 0; i < bt->num_frames; i++) {
ast_log(LOG_DEBUG, "#%d: [%p] %s\n", i, bt->addresses[i], strings[i]);
}
+
+ /* MALLOC_DEBUG will erroneously report an error here, unless we undef the macro. */
+#undef free
free(strings);
} else {
ast_debug(1, "Could not allocate memory for backtrace\n");
Modified: trunk/main/pbx.c
URL: http://svn.asterisk.org/svn-view/asterisk/trunk/main/pbx.c?view=diff&rev=194101&r1=194100&r2=194101
==============================================================================
--- trunk/main/pbx.c (original)
+++ trunk/main/pbx.c Tue May 12 19:13:43 2009
@@ -7908,12 +7908,10 @@
/* If we are adding a hint evalulate in variables and global variables */
if (priority == PRIORITY_HINT && strstr(application, "${") && !strstr(extension, "_")) {
- struct ast_channel c = {0, };
-
- ast_copy_string(c.exten, extension, sizeof(c.exten));
- ast_copy_string(c.context, con->name, sizeof(c.context));
- pbx_substitute_variables_helper(&c, application, expand_buf, sizeof(expand_buf));
+ struct ast_channel *c = ast_channel_alloc(0, AST_STATE_DOWN, 0, 0, "", extension, con->name, 0, "Bogus/%s", __PRETTY_FUNCTION__);
+ pbx_substitute_variables_helper(c, application, expand_buf, sizeof(expand_buf));
application = expand_buf;
+ ast_channel_release(c);
}
length = sizeof(struct ast_exten);
More information about the asterisk-commits
mailing list