diff src/undo.c @ 12216:e971ef6c0dee v8.0.0988

patch 8.0.0988: warning from Covscan about using NULL pointer commit https://github.com/vim/vim/commit/829aa64cf5a113bb683ddf8b32e483e0696602ea Author: Bram Moolenaar <Bram@vim.org> Date: Wed Aug 23 22:32:35 2017 +0200 patch 8.0.0988: warning from Covscan about using NULL pointer Problem: Warning from Covscan about using NULL pointer. Solution: Add extra check for NULL. (zdohnal)
author Christian Brabandt <cb@256bit.org>
date Wed, 23 Aug 2017 22:45:04 +0200
parents bc0fee081e1e
children 1ff5e5dfa9b0
line wrap: on
line diff
--- a/src/undo.c
+++ b/src/undo.c
@@ -921,7 +921,7 @@ undo_write(bufinfo_T *bi, char_u *ptr, s
     static int
 undo_flush(bufinfo_T *bi)
 {
-    if (bi->bi_buffer != NULL && bi->bi_used > 0)
+    if (bi->bi_buffer != NULL && bi->bi_state != NULL && bi->bi_used > 0)
     {
 	crypt_encode_inplace(bi->bi_state, bi->bi_buffer, bi->bi_used);
 	if (fwrite(bi->bi_buffer, bi->bi_used, (size_t)1, bi->bi_fp) != 1)