Add robstness in case of error during sqlite request execution 46/27946/1 accepted/tizen/common/20140923.145814 submit/tizen/20140923.121012 submit/tizen_ivi/20140924.000000
authorBaptiste DURAND <baptiste.durand@open.eurogiciel.org>
Tue, 23 Sep 2014 11:53:03 +0000 (13:53 +0200)
committerBaptiste DURAND <baptiste.durand@open.eurogiciel.org>
Tue, 23 Sep 2014 11:54:23 +0000 (13:54 +0200)
BUG=TC-1624

Change-Id: I30aac4d39d81283f41a5c894b9e842fcd2ad1c64
Signed-off-by: Baptiste DURAND <baptiste.durand@open.eurogiciel.org>
src/ail_db.c

index bfa3ced..e878317 100755 (executable)
@@ -544,7 +544,7 @@ ail_error_e db_finalize(sqlite3_stmt *stmt)
 ail_error_e do_db_exec(const char *query, sqlite3 * fileSQL)
 {
        int ret;
-       char *errmsg;
+       char *errmsg = NULL;
 
        retv_if(!query, AIL_ERROR_INVALID_PARAMETER);
        retv_if(!fileSQL, AIL_ERROR_DB_FAILED);
@@ -553,7 +553,8 @@ ail_error_e do_db_exec(const char *query, sqlite3 * fileSQL)
        if (ret != SQLITE_OK) {
                _E("Cannot execute this query - %s. because %s",
                                query, errmsg? errmsg:"uncatched error");
-               sqlite3_free(errmsg);
+               if(errmsg)
+                       sqlite3_free(errmsg);
                return AIL_ERROR_DB_FAILED;
        }