summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBram Moolenaar <Bram@vim.org>2010-07-25 16:05:19 +0200
committerBram Moolenaar <Bram@vim.org>2010-07-25 16:05:19 +0200
commitfa0ff9aedf9515638e15726141c4a08ca4e05255 (patch)
tree5905078139923e4721338380895942e33f09844f /src
parent8d9b40e71ab62f43c65a52225cb833ecc0d1bf6b (diff)
downloadvim-git-fa0ff9aedf9515638e15726141c4a08ca4e05255.tar.gz
Fix: editing a not encrypted file after a crypted file messed up reading the
text from an undo file.
Diffstat (limited to 'src')
-rw-r--r--src/fileio.c2
-rw-r--r--src/undo.c6
2 files changed, 4 insertions, 4 deletions
diff --git a/src/fileio.c b/src/fileio.c
index 1c0ac8580..c7a2b749e 100644
--- a/src/fileio.c
+++ b/src/fileio.c
@@ -2953,7 +2953,7 @@ check_for_cryptkey(cryptkey, ptr, sizep, filesizep, newfile, fname, did_ask)
}
/* When starting to edit a new file which does not have encryption, clear
* the 'key' option, except when starting up (called with -x argument) */
- else if (newfile && *curbuf->b_p_key && !starting)
+ else if (newfile && *curbuf->b_p_key != NUL && !starting)
set_option_value((char_u *)"key", 0L, (char_u *)"", OPT_LOCAL);
return cryptkey;
diff --git a/src/undo.c b/src/undo.c
index 6d50cc839..eb887d8b7 100644
--- a/src/undo.c
+++ b/src/undo.c
@@ -888,7 +888,7 @@ read_string_decrypt(buf, fd, len)
ptr = read_string(fd, len);
#ifdef FEAT_CRYPT
- if (ptr != NULL || *buf->b_p_key != NUL)
+ if (ptr != NULL && *buf->b_p_key != NUL)
crypt_decode(ptr, len);
#endif
return ptr;
@@ -909,7 +909,7 @@ serialize_header(fp, buf, hash)
/* If the buffer is encrypted then all text bytes following will be
* encrypted. Numbers and other info is not crypted. */
#ifdef FEAT_CRYPT
- if (*buf->b_p_key)
+ if (*buf->b_p_key != NUL)
{
char_u *header;
int header_len;
@@ -1475,7 +1475,7 @@ u_write_undo(name, forceit, buf, hash)
if (serialize_header(fp, buf, hash) == FAIL)
goto write_error;
#ifdef FEAT_CRYPT
- if (*buf->b_p_key)
+ if (*buf->b_p_key != NUL)
do_crypt = TRUE;
#endif