[asterisk-commits] russell: branch 1.8 r317837 - /branches/1.8/addons/app_mysql.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri May 6 14:24:19 CDT 2011


Author: russell
Date: Fri May  6 14:24:11 2011
New Revision: 317837

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=317837
Log:
Fix a crash in the MySQL() application.

This code was not handling channel datastores safely.  The channel
must be locked.

(closes issue #17964)
Reported by: wuwu
Patches:
      issue17964_addon_1.6.2_svn.patch uploaded by seanbright (license 71)
Tested by: wuwu

Modified:
    branches/1.8/addons/app_mysql.c

Modified: branches/1.8/addons/app_mysql.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/addons/app_mysql.c?view=diff&rev=317837&r1=317836&r2=317837
==============================================================================
--- branches/1.8/addons/app_mysql.c (original)
+++ branches/1.8/addons/app_mysql.c Fri May  6 14:24:11 2011
@@ -546,7 +546,10 @@
 	result = 0;
 
 	if (autoclear) {
-		struct ast_datastore *mysql_store = ast_channel_datastore_find(chan, &mysql_ds_info, NULL);
+		struct ast_datastore *mysql_store = NULL;
+
+		ast_channel_lock(chan);
+		mysql_store = ast_channel_datastore_find(chan, &mysql_ds_info, NULL);
 		if (!mysql_store) {
 			if (!(mysql_store = ast_datastore_alloc(&mysql_ds_info, NULL))) {
 				ast_log(LOG_WARNING, "Unable to allocate new datastore.\n");
@@ -555,6 +558,7 @@
 				ast_channel_datastore_add(chan, mysql_store);
 			}
 		}
+		ast_channel_unlock(chan);
 	}
 	ast_mutex_lock(&_mysql_mutex);
 




More information about the asterisk-commits mailing list