Skip to content

Commit

Permalink
fix(notmuch): null DB pointer on open failure
Browse files Browse the repository at this point in the history
This commit nulls 'db' if there's an error in opening the database. The
discussion on #3082 revealed that a failure to open the database is not
guaranteed to NULL the database pointer. So our existing NULL checks in
'nm_db_do_open()' won't function and we may return an invalid non-NULL
database pointer.
  • Loading branch information
austin-ray authored and flatcap committed Oct 23, 2021
1 parent 61c2d8a commit e9f3170
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions notmuch/db.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,11 @@ notmuch_database_t *nm_db_do_open(const char *filename, bool writable, bool verb
ct++;
} while (true);

if (st != NOTMUCH_STATUS_SUCCESS)
{
db = NULL;
}

if (verbose)
{
if (!db)
Expand Down

0 comments on commit e9f3170

Please sign in to comment.