diff src/undo.c @ 2251:646d34788036 vim73

Fix a few compiler warnings. Fix crash with encrypted undo file.
author Bram Moolenaar <bram@vim.org>
date Sun, 06 Jun 2010 14:20:26 +0200
parents 4e0124f5aee2
children 771f21e35ec5
line wrap: on
line diff
--- a/src/undo.c
+++ b/src/undo.c
@@ -1503,13 +1503,19 @@ u_read_undo(name, hash, orig_name)
     if (version == UF_VERSION_CRYPT)
     {
 #ifdef FEAT_CRYPT
+	if (*curbuf->b_p_key == NUL)
+	{
+	    EMSG2(_("E832: Non-encrypted file has encrypted undo file: %s"),
+								   file_name);
+	    goto error;
+	}
 	if (prepare_crypt_read(fp) == FAIL)
 	{
 	    EMSG2(_("E826: Undo file decryption failed: %s"), file_name);
 	    goto error;
 	}
 #else
-        EMSG2(_("E826: Undo file is encrypted: %s"), file_name);
+        EMSG2(_("E827: Undo file is encrypted: %s"), file_name);
         goto error;
 #endif
     }