]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
res_config_pgsql: Release table locks where appropriate
authorSean Bright <sean.bright@gmail.com>
Tue, 28 Feb 2017 15:41:45 +0000 (10:41 -0500)
committerSean Bright <sean.bright@gmail.com>
Tue, 28 Feb 2017 15:44:01 +0000 (09:44 -0600)
The find_table() functions NULL or a locked table pointer. We are
not consistently calling release_table() in failure paths.

Change-Id: I6f665b455799c84b036e5b34904b82b05eab9544

res/res_config_pgsql.c

index 2c51a53f317693a48c018f6260fee3c5353e09d4..3c91f9d1354e0f18ee01de6fd974b844efdc5542 100644 (file)
@@ -735,6 +735,7 @@ static int update_pgsql(const char *database, const char *tablename, const char
        ast_mutex_lock(&pgsql_lock);
        if (!pgsql_reconnect(database)) {
                ast_mutex_unlock(&pgsql_lock);
+               release_table(table);
                return -1;
        }
 
@@ -880,6 +881,7 @@ static int update2_pgsql(const char *database, const char *tablename, const stru
        ast_mutex_lock(&pgsql_lock);
        if (!pgsql_reconnect(database)) {
                ast_mutex_unlock(&pgsql_lock);
+               release_table(table);
                return -1;
        }
 
@@ -1324,6 +1326,7 @@ static int require_pgsql(const char *database, const char *tablename, va_list ap
 
                                if (pgsql_exec(database, tablename, ast_str_buffer(sql), &result) != 0) {
                                        ast_mutex_unlock(&pgsql_lock);
+                                       release_table(table);
                                        return -1;
                                }