shada: Fix non-writeable ShaDa directory handling

Before this change,

    nvim -i /etc/shada

segfaults on exit if the file does not exist and user does not have
permissions to create the file at /etc/shada.

Closes #5296
Reported in #5277
https://github.com/neovim/neovim/issues/5277#issuecomment-243937255
This commit is contained in:
ZyX
2016-09-05 10:16:56 +03:00
committed by Justin M. Keyes
parent cd321b7d0f
commit 6127eaef05
3 changed files with 24 additions and 5 deletions

View File

@@ -2976,7 +2976,7 @@ shada_write_file_nomerge: {}
if (sd_writer.cookie == NULL) {
xfree(fname);
xfree(tempname);
if (sd_reader.close != NULL) {
if (sd_reader.cookie != NULL) {
sd_reader.close(&sd_reader);
}
return FAIL;