When executing a set of query , if at one moment a query contains nothing (i.e empty string/SQL comment only/empty spaces) the execute will generate a segfault here is a sample code
int SqliteModel::import_sql_file(
const std::string &sqlFilePath
) {
try {
std::ifstream f(sqlFilePath.c_str());
std::string fileStr(
(std::istreambuf_iterator<char>(f)),
std::istreambuf_iterator<char>()
);
sqliteDb << fileStr << cppdb::exec;
size_t current = 0;
size_t next = -1;
do
{
current = next + 1;
next = fileStr.find_first_of( ";", current );
std::string tmpRequest = fileStr.substr( current, next - current );
sqliteDb << tmpRequest << cppdb::exec;
} while (next != std::string::npos);
} catch(std::exception const &e) { BOOSTER_ERROR("cppcms") << e.what(); return 1; } return 0;
}
and it will segfault (no exception, a old goold segfault) when I try to execute a string containing nothing or a comment or a set of space with nothing less
the backtrace generates
at /home/allan/Desktop/projet/cppdb-0.3.0/drivers/sqlite3_backend.cpp:226
at /home/allan/Desktop/projet/cppdb-0.3.0/src/backend.cpp:146
at /home/allan/Desktop/projet/cppdb-0.3.0/src/frontend.cpp:218
which is in line 226 of sqlite3_backend of cppdb
sqlite3_clear_bindings(st_);
st_ being a NULL pointer (0x0)
Anonymous