mirror of
https://github.com/cuberite/SQLiteCpp.git
synced 2025-08-05 02:06:02 -04:00
Fixed two SQLiteC++ Coverity Issues in Database::execAndGet() and Database::tableExists()
- adding a (void) cast in front of query.executeStep() - adding comments explaining how errors are handled in this thow methods Thank you to Donald Jones and Mark Pashley of Ubiquisys for reporting this to me.
This commit is contained in:
parent
3442a9a002
commit
4d828fe6b1
@ -59,7 +59,7 @@ int Database::exec(const char* apQueries) // throw(SQLite::Exception);
|
|||||||
Column Database::execAndGet(const char* apQuery) // throw(SQLite::Exception)
|
Column Database::execAndGet(const char* apQuery) // throw(SQLite::Exception)
|
||||||
{
|
{
|
||||||
Statement query(*this, apQuery);
|
Statement query(*this, apQuery);
|
||||||
query.executeStep();
|
(void)query.executeStep(); // Can return false if no result, which will throw next line in getColumn()
|
||||||
return query.getColumn(0);
|
return query.getColumn(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ bool Database::tableExists(const char* apTableName) // throw(SQLite::Exception)
|
|||||||
{
|
{
|
||||||
Statement query(*this, "SELECT count(*) FROM sqlite_master WHERE type='table' AND name=?");
|
Statement query(*this, "SELECT count(*) FROM sqlite_master WHERE type='table' AND name=?");
|
||||||
query.bind(1, apTableName);
|
query.bind(1, apTableName);
|
||||||
query.executeStep();
|
(void)query.executeStep(); // Cannot return false, as the above query always return a result
|
||||||
int Nb = query.getColumn(0);
|
int Nb = query.getColumn(0);
|
||||||
return (1 == Nb);
|
return (1 == Nb);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user