]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
CHAOS: avoid crash if string create fails 79/1279/4
authorScott Griepentrog <scott@griepentrog.com>
Thu, 17 Sep 2015 21:34:41 +0000 (16:34 -0500)
committerScott Griepentrog <sgriepentrog@digium.com>
Fri, 18 Sep 2015 18:52:46 +0000 (13:52 -0500)
Validate string buffer allocation before using them.

ASTERISK-25323

Change-Id: Ib9c338bdc1e53fb8b81366f0b39482b83ef56ce0

res/res_config_sqlite.c

index fe2fb3cdb468ccdbe97ee38d3146b1b4ac9dca4c..b97ef7a86ae70290dc7361957e233c6499ba3f64 100644 (file)
@@ -781,8 +781,16 @@ static int cdr_handler(struct ast_cdr *cdr)
        struct ast_str *sql1 = ast_str_create(160), *sql2 = ast_str_create(16);
        int first = 1;
 
+       if (!sql1 || !sql2) {
+               ast_free(sql1);
+               ast_free(sql2);
+               return -1;
+       }
+
        if (!tbl) {
                ast_log(LOG_WARNING, "No such table: %s\n", cdr_table);
+               ast_free(sql1);
+               ast_free(sql2);
                return -1;
        }