memline: Fix “NULL pointer dereference” warning

It was actually a false positive indicating always-true condition, not real 
dereference.
This commit is contained in:
ZyX
2017-04-16 20:55:29 +03:00
parent 2394c9f2b7
commit 10ce00efa8

View File

@@ -3362,29 +3362,32 @@ static char *findswapname(buf_T *buf, char **dirp, char *old_fname,
} }
if (swap_exists_action != SEA_NONE && choice == 0) { if (swap_exists_action != SEA_NONE && choice == 0) {
char *name; const char *const sw_msg_1 = _("Swap file \"");
const char *const sw_msg_2 = _("\" already exists!");
const size_t fname_len = strlen(fname); const size_t fname_len = strlen(fname);
name = xmalloc(fname_len const size_t sw_msg_1_len = strlen(sw_msg_1);
+ strlen(_("Swap file \"")) const size_t sw_msg_2_len = strlen(sw_msg_2);
+ strlen(_("\" already exists!")) + 5);
STRCPY(name, _("Swap file \"")); const size_t name_len = sw_msg_1_len + fname_len + sw_msg_2_len + 5;
home_replace(NULL, (char_u *) fname, (char_u *)&name[strlen(name)],
fname_len, true); char *const name = xmalloc(name_len);
STRCAT(name, _("\" already exists!")); memcpy(name, sw_msg_1, sw_msg_1_len + 1);
choice = do_dialog(VIM_WARNING, home_replace(NULL, (char_u *)fname, (char_u *)&name[sw_msg_1_len],
(char_u *)_("VIM - ATTENTION"), fname_len, true);
(char_u *)(name == NULL xstrlcat(name, sw_msg_2, name_len);
? _("Swap file already exists!") choice = do_dialog(VIM_WARNING, (char_u *)_("VIM - ATTENTION"),
: name), (char_u *)name,
# if defined(UNIX) # if defined(UNIX)
process_still_running process_still_running
? (char_u *)_( ? (char_u *)_(
"&Open Read-Only\n&Edit anyway\n&Recover\n&Quit\n&Abort") : "&Open Read-Only\n&Edit anyway\n&Recover"
"\n&Quit\n&Abort") :
# endif # endif
(char_u *)_( (char_u *)_(
"&Open Read-Only\n&Edit anyway\n&Recover\n&Delete it\n&Quit\n&Abort"), "&Open Read-Only\n&Edit anyway\n&Recover"
1, NULL, FALSE); "\n&Delete it\n&Quit\n&Abort"),
1, NULL, false);
# if defined(UNIX) # if defined(UNIX)
if (process_still_running && choice >= 4) if (process_still_running && choice >= 4)