sqlite: Allow query arguments to be freed before starting the enumeration
authorTobias Brunner <tobias@strongswan.org>
Wed, 30 Apr 2014 07:30:17 +0000 (09:30 +0200)
committerTobias Brunner <tobias@strongswan.org>
Wed, 30 Apr 2014 07:37:32 +0000 (09:37 +0200)
By marking the string/blob arguments as transient, SQLite will copy and
free them automatically.

src/libstrongswan/plugins/sqlite/sqlite_database.c

index 7b47678..6757074 100644 (file)
@@ -101,13 +101,15 @@ static sqlite3_stmt* run(private_sqlite_database_t *this, char *sql,
                                case DB_TEXT:
                                {
                                        const char *text = va_arg(*args, const char*);
-                                       res = sqlite3_bind_text(stmt, i, text, -1, SQLITE_STATIC);
+                                       res = sqlite3_bind_text(stmt, i, text, -1,
+                                                                                       SQLITE_TRANSIENT);
                                        break;
                                }
                                case DB_BLOB:
                                {
                                        chunk_t c = va_arg(*args, chunk_t);
-                                       res = sqlite3_bind_blob(stmt, i, c.ptr, c.len, SQLITE_STATIC);
+                                       res = sqlite3_bind_blob(stmt, i, c.ptr, c.len,
+                                                                                       SQLITE_TRANSIENT);
                                        break;
                                }
                                case DB_DOUBLE: