]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fix a crash in the MySQL() application.
authorRussell Bryant <russell@russellbryant.com>
Fri, 6 May 2011 19:24:11 +0000 (19:24 +0000)
committerRussell Bryant <russell@russellbryant.com>
Fri, 6 May 2011 19:24:11 +0000 (19:24 +0000)
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

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.8@317837 65c4cc65-6c06-0410-ace0-fbb531ad65f3

addons/app_mysql.c

index b65b5bb939c5a7b7c4ba1a54b111cc3602767fb2..589b238237c1c88a57329bf641f62fcf4be8d972 100644 (file)
@@ -546,7 +546,10 @@ static int MYSQL_exec(struct ast_channel *chan, const char *data)
        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 @@ static int MYSQL_exec(struct ast_channel *chan, const char *data)
                                ast_channel_datastore_add(chan, mysql_store);
                        }
                }
+               ast_channel_unlock(chan);
        }
        ast_mutex_lock(&_mysql_mutex);