mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-25 12:28:09 +01:00
lib/load_config: deallocate / NULL database on fatal error
This fixes a potential memory leak, and makes the behaviour of notmuch_database_load_config (somewhat) consistent with n_d_{open,create} with config.
This commit is contained in:
parent
8f0b84789d
commit
fe51c275fc
2 changed files with 7 additions and 1 deletions
|
@ -871,6 +871,13 @@ notmuch_database_load_config (const char *database_path,
|
||||||
if (status_string)
|
if (status_string)
|
||||||
*status_string = message;
|
*status_string = message;
|
||||||
|
|
||||||
|
if (status &&
|
||||||
|
status != NOTMUCH_STATUS_NO_DATABASE
|
||||||
|
&& status != NOTMUCH_STATUS_NO_CONFIG) {
|
||||||
|
notmuch_database_destroy (notmuch);
|
||||||
|
notmuch = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if (database)
|
if (database)
|
||||||
*database = notmuch;
|
*database = notmuch;
|
||||||
|
|
||||||
|
|
|
@ -942,7 +942,6 @@ EOF
|
||||||
test_expect_equal_file EXPECTED OUTPUT
|
test_expect_equal_file EXPECTED OUTPUT
|
||||||
|
|
||||||
test_begin_subtest "load_config: database set to NULL on fatal error"
|
test_begin_subtest "load_config: database set to NULL on fatal error"
|
||||||
test_subtest_known_broken
|
|
||||||
cat c_head3 - c_tail3 <<'EOF' | test_C
|
cat c_head3 - c_tail3 <<'EOF' | test_C
|
||||||
notmuch_status_t st = notmuch_database_load_config("relative", NULL, NULL, &db, NULL);
|
notmuch_status_t st = notmuch_database_load_config("relative", NULL, NULL, &db, NULL);
|
||||||
EOF
|
EOF
|
||||||
|
|
Loading…
Reference in a new issue