Added check for null pointer before accessing and leaving SQLite mutex.#2276
Merged
aleks-f merged 2 commits intopocoproject:developfrom Apr 10, 2018
Merged
Conversation
aleks-f
requested changes
Apr 9, 2018
SQL/SQLite/src/Utility.cpp
Outdated
| Utility::SQLiteMutex::SQLiteMutex(sqlite3* pDB) | ||
| { | ||
| sqlite3_mutex_enter(_pMutex); | ||
| _pMutex = (pDB) ? sqlite3_db_mutex(pDB) : NULL; |
Member
There was a problem hiding this comment.
a couple of things:
- this is ok, but please leave it in initialization
- use 0, not NULL
Member
There was a problem hiding this comment.
strictly speaking nullptr would be the right thing to do, but since 1.x releases do not yet unconditionally support c++11, let's have 0
Contributor
Author
There was a problem hiding this comment.
Added the changes. Thanks for pointing out!
Member
|
@jiajen thanks, just so it is properly tracked, would you mind opening issue and sending the same fix to poco-1.9.1 branch |
aleks-f
approved these changes
Apr 9, 2018
This was referenced Apr 9, 2018
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A null pointer dereference occurs when a SQLite Session fails to be constructed. This can be recreated with the following code:
The issue occurs when the database cannot be created and attempts to throw an exception. However, since all exceptions invoke a SQLite mutex (since the fix for issue #2012),
sqlite3_db_mutex(pDB)causes a segmentation fault whenpDBis null which can occur if the database cannot be created. Checking for a null pointer before entering and leaving the SQLite mutex solves the problem.