aboutsummaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
authorFelipe Oliveira Carvalho <felipekde@gmail.com>2014-03-28 00:11:57 -0300
committerThiago de Arruda <tpadilha84@gmail.com>2014-03-31 07:31:47 -0300
commit5afc1161ca31a643bf0cd14f7a96f1a2b953efec (patch)
tree0dd01dc529b884910bc0d27cc2b06849936575dc /src/main.c
parentde1575f3ea9dd2ab66198537a0a3788fba0e06bb (diff)
downloadrneovim-5afc1161ca31a643bf0cd14f7a96f1a2b953efec.tar.gz
rneovim-5afc1161ca31a643bf0cd14f7a96f1a2b953efec.tar.bz2
rneovim-5afc1161ca31a643bf0cd14f7a96f1a2b953efec.zip
Avoid a seg fault when exiting after OOM error
I'm debugging OOM behavior using http://www.nongnu.org/failmalloc/ on Linux. gdb environment: ``` set env LD_PRELOAD=libfailmalloc.so set env FAILMALLOC_SPACE=0xF00000 ``` SEGV was happening like this: ``` Starting program: /home/felipe/code/neovim/build/bin/nvim [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Vim: Error: Out of memory. Program received signal SIGSEGV, Segmentation fault. 0x00000000004d3719 in getout (exitval=1) at /home/felipe/code/neovim/src/main.c:836 836 if (*p_viminfo != NUL) (gdb) ``` After the fix it works as expected: ``` (gdb) set environment LD_PRELOAD=libfailmalloc.so (gdb) set environment FAILMALLOC_SPACE=0xF00000 (gdb) r Starting program: /home/felipe/code/neovim/build/bin/nvim [Thread debugging using libthread_db enabled] Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1". Vim: Error: Out of memory. Vim: Finished. [Inferior 1 (process 21505) exited with code 01] (gdb) ```
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/main.c b/src/main.c
index b1e6aa7810..a8a2efbc8a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -834,7 +834,7 @@ void getout(int exitval)
apply_autocmds(EVENT_VIMLEAVEPRE, NULL, NULL, FALSE, curbuf);
}
- if (*p_viminfo != NUL)
+ if (p_viminfo && *p_viminfo != NUL)
/* Write out the registers, history, marks etc, to the viminfo file */
write_viminfo(NULL, FALSE);