To: vim_dev@googlegroups.com Subject: Patch 8.0.1496 Fcc: outbox From: Bram Moolenaar Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ------------ Patch 8.0.1496 Problem: Clearing a pointer takes two lines. Solution: Add VIM_CLEAR() and replace vim_clear(). (Hirohito Higashi, closes #2629) Files: src/buffer.c, src/channel.c, src/crypt.c, src/edit.c, src/eval.c, src/evalfunc.c, src/ex_cmds.c, src/ex_cmds2.c, src/ex_docmd.c, src/ex_getln.c, src/fileio.c, src/gui_gtk_x11.c, src/gui_photon.c, src/gui_w32.c, src/gui_x11.c, src/hardcopy.c, src/if_cscope.c, src/macros.h, src/main.c, src/mark.c, src/mbyte.c, src/memfile.c, src/memline.c, src/menu.c, src/message.c, src/misc1.c, src/misc2.c, src/netbeans.c, src/normal.c, src/ops.c, src/option.c, src/os_amiga.c, src/os_mac_conv.c, src/os_mswin.c, src/os_unix.c, src/os_win32.c, src/popupmnu.c, src/proto/misc2.pro, src/quickfix.c, src/regexp.c, src/regexp_nfa.c, src/screen.c, src/search.c, src/spell.c, src/spellfile.c, src/syntax.c, src/tag.c, src/term.c, src/terminal.c, src/ui.c, src/undo.c, src/userfunc.c, src/window.c *** ../vim-8.0.1495/src/buffer.c 2018-02-03 17:36:22.626091882 +0100 --- src/buffer.c 2018-02-10 18:34:22.869553122 +0100 *************** *** 944,951 **** map_clear_int(buf, MAP_ALL_MODES, TRUE, TRUE); /* clear local abbrevs */ #endif #ifdef FEAT_MBYTE ! vim_free(buf->b_start_fenc); ! buf->b_start_fenc = NULL; #endif } --- 944,950 ---- map_clear_int(buf, MAP_ALL_MODES, TRUE, TRUE); /* clear local abbrevs */ #endif #ifdef FEAT_MBYTE ! VIM_CLEAR(buf->b_start_fenc); #endif } *************** *** 2037,2046 **** if ((ffname != NULL && (buf->b_ffname == NULL || buf->b_sfname == NULL)) || buf->b_wininfo == NULL) { ! vim_free(buf->b_ffname); ! buf->b_ffname = NULL; ! vim_free(buf->b_sfname); ! buf->b_sfname = NULL; if (buf != curbuf) free_buffer(buf); return NULL; --- 2036,2043 ---- if ((ffname != NULL && (buf->b_ffname == NULL || buf->b_sfname == NULL)) || buf->b_wininfo == NULL) { ! VIM_CLEAR(buf->b_ffname); ! VIM_CLEAR(buf->b_sfname); if (buf != curbuf) free_buffer(buf); return NULL; *************** *** 3136,3145 **** if (ffname == NULL || *ffname == NUL) { /* Removing the name. */ ! vim_free(buf->b_ffname); ! vim_free(buf->b_sfname); ! buf->b_ffname = NULL; ! buf->b_sfname = NULL; #ifdef UNIX st.st_dev = (dev_T)-1; #endif --- 3133,3140 ---- if (ffname == NULL || *ffname == NUL) { /* Removing the name. */ ! VIM_CLEAR(buf->b_ffname); ! VIM_CLEAR(buf->b_sfname); #ifdef UNIX st.st_dev = (dev_T)-1; #endif *************** *** 4261,4268 **** if (*skipdigits(str) == NUL) { num = atoi((char *)str); ! vim_free(str); ! str = NULL; itemisflag = FALSE; } } --- 4256,4262 ---- if (*skipdigits(str) == NUL) { num = atoi((char *)str); ! VIM_CLEAR(str); itemisflag = FALSE; } } *** ../vim-8.0.1495/src/channel.c 2018-01-31 20:51:40.297835998 +0100 --- src/channel.c 2018-02-10 18:34:22.869553122 +0100 *************** *** 317,324 **** /* If there is no callback then nobody can get readahead. If the fd is * closed and there is no readahead then the callback won't be called. */ has_sock_msg = channel->ch_part[PART_SOCK].ch_fd != INVALID_FD ! || channel->ch_part[PART_SOCK].ch_head.rq_next != NULL ! || channel->ch_part[PART_SOCK].ch_json_head.jq_next != NULL; has_out_msg = channel->ch_part[PART_OUT].ch_fd != INVALID_FD || channel->ch_part[PART_OUT].ch_head.rq_next != NULL || channel->ch_part[PART_OUT].ch_json_head.jq_next != NULL; --- 317,324 ---- /* If there is no callback then nobody can get readahead. If the fd is * closed and there is no readahead then the callback won't be called. */ has_sock_msg = channel->ch_part[PART_SOCK].ch_fd != INVALID_FD ! || channel->ch_part[PART_SOCK].ch_head.rq_next != NULL ! || channel->ch_part[PART_SOCK].ch_json_head.jq_next != NULL; has_out_msg = channel->ch_part[PART_OUT].ch_fd != INVALID_FD || channel->ch_part[PART_OUT].ch_head.rq_next != NULL || channel->ch_part[PART_OUT].ch_json_head.jq_next != NULL; *************** *** 2978,2985 **** channel_clear(channel_T *channel) { ch_log(channel, "Clearing channel"); ! vim_free(channel->ch_hostname); ! channel->ch_hostname = NULL; channel_clear_one(channel, PART_SOCK); channel_clear_one(channel, PART_OUT); channel_clear_one(channel, PART_ERR); --- 2978,2984 ---- channel_clear(channel_T *channel) { ch_log(channel, "Clearing channel"); ! VIM_CLEAR(channel->ch_hostname); channel_clear_one(channel, PART_SOCK); channel_clear_one(channel, PART_OUT); channel_clear_one(channel, PART_ERR); *** ../vim-8.0.1495/src/crypt.c 2016-08-29 22:42:20.000000000 +0200 --- src/crypt.c 2018-02-10 18:34:22.873553095 +0100 *************** *** 118,123 **** --- 118,126 ---- NULL, NULL, crypt_blowfish_encode, crypt_blowfish_decode, }, + + /* NOTE: when adding a new method, use some random bytes for the magic key, + * to avoid that a text file is recognized as encrypted. */ }; #define CRYPT_MAGIC_LEN 12 /* cannot change */ *************** *** 349,358 **** state = crypt_create(method_nr, key, salt, salt_len, seed, seed_len); if (state == NULL) ! { ! vim_free(*header); ! *header = NULL; ! } return state; } --- 352,358 ---- state = crypt_create(method_nr, key, salt, salt_len, seed, seed_len); if (state == NULL) ! VIM_CLEAR(*header); return state; } *** ../vim-8.0.1495/src/edit.c 2018-02-10 18:15:00.754098808 +0100 --- src/edit.c 2018-02-10 18:34:22.873553095 +0100 *************** *** 2939,2945 **** if (compl_match_array != NULL) { pum_undisplay(); ! vim_clear((void **)&compl_match_array); } } --- 2939,2945 ---- if (compl_match_array != NULL) { pum_undisplay(); ! VIM_CLEAR(compl_match_array); } } *************** *** 3441,3448 **** compl_T *match; int i; ! vim_clear((void **)&compl_pattern); ! vim_clear((void **)&compl_leader); if (compl_first_match == NULL) return; --- 3441,3448 ---- compl_T *match; int i; ! VIM_CLEAR(compl_pattern); ! VIM_CLEAR(compl_leader); if (compl_first_match == NULL) return; *************** *** 3474,3483 **** compl_cont_status = 0; compl_started = FALSE; compl_matches = 0; ! vim_clear((void **)&compl_pattern); ! vim_clear((void **)&compl_leader); edit_submode_extra = NULL; ! vim_clear((void **)&compl_orig_text); compl_enter_selects = FALSE; /* clear v:completed_item */ set_vim_var_dict(VV_COMPLETED_ITEM, dict_alloc_lock(VAR_FIXED)); --- 3474,3483 ---- compl_cont_status = 0; compl_started = FALSE; compl_matches = 0; ! VIM_CLEAR(compl_pattern); ! VIM_CLEAR(compl_leader); edit_submode_extra = NULL; ! VIM_CLEAR(compl_orig_text); compl_enter_selects = FALSE; /* clear v:completed_item */ set_vim_var_dict(VV_COMPLETED_ITEM, dict_alloc_lock(VAR_FIXED)); *************** *** 5584,5591 **** if (compl_orig_text == NULL || ins_compl_add(compl_orig_text, -1, p_ic, NULL, NULL, 0, ORIGINAL_TEXT, FALSE) != OK) { ! vim_clear((void **)&compl_pattern); ! vim_clear((void **)&compl_orig_text); return FAIL; } --- 5584,5591 ---- if (compl_orig_text == NULL || ins_compl_add(compl_orig_text, -1, p_ic, NULL, NULL, 0, ORIGINAL_TEXT, FALSE) != OK) { ! VIM_CLEAR(compl_pattern); ! VIM_CLEAR(compl_orig_text); return FAIL; } *************** *** 7214,7222 **** void free_last_insert(void) { ! vim_clear((void **)&last_insert); # ifdef FEAT_INS_EXPAND ! vim_clear((void **)&compl_orig_text); # endif } #endif --- 7214,7222 ---- void free_last_insert(void) { ! VIM_CLEAR(last_insert); # ifdef FEAT_INS_EXPAND ! VIM_CLEAR(compl_orig_text); # endif } #endif *************** *** 7844,7850 **** static void replace_flush(void) { ! vim_clear((void **)&replace_stack); replace_stack_len = 0; replace_stack_nr = 0; } --- 7844,7850 ---- static void replace_flush(void) { ! VIM_CLEAR(replace_stack); replace_stack_len = 0; replace_stack_nr = 0; } *** ../vim-8.0.1495/src/eval.c 2017-12-16 18:26:56.622992523 +0100 --- src/eval.c 2018-02-10 18:34:22.873553095 +0100 *************** *** 361,370 **** { p = &vimvars[i]; if (p->vv_di.di_tv.v_type == VAR_STRING) ! { ! vim_free(p->vv_str); ! p->vv_str = NULL; ! } else if (p->vv_di.di_tv.v_type == VAR_LIST) { list_unref(p->vv_list); --- 361,367 ---- { p = &vimvars[i]; if (p->vv_di.di_tv.v_type == VAR_STRING) ! VIM_CLEAR(p->vv_str); else if (p->vv_di.di_tv.v_type == VAR_LIST) { list_unref(p->vv_list); *************** *** 569,582 **** } /* free the collected output */ ! vim_free(redir_ga.ga_data); ! redir_ga.ga_data = NULL; ! vim_free(redir_lval); ! redir_lval = NULL; } ! vim_free(redir_varname); ! redir_varname = NULL; } # if defined(FEAT_MBYTE) || defined(PROTO) --- 566,576 ---- } /* free the collected output */ ! VIM_CLEAR(redir_ga.ga_data); ! VIM_CLEAR(redir_lval); } ! VIM_CLEAR(redir_varname); } # if defined(FEAT_MBYTE) || defined(PROTO) *************** *** 1009,1018 **** tv = (typval_T *)alloc(sizeof(typval_T)); if (tv != NULL && eval0(arg, tv, nextcmd, TRUE) == FAIL) ! { ! vim_free(tv); ! tv = NULL; ! } return tv; } --- 1003,1009 ---- tv = (typval_T *)alloc(sizeof(typval_T)); if (tv != NULL && eval0(arg, tv, nextcmd, TRUE) == FAIL) ! VIM_CLEAR(tv); return tv; } *************** *** 3213,3220 **** if (vidx < VV_LEN) return cat_prefix_varname('v', (char_u *)vimvars[vidx++].vv_name); ! vim_free(varnamebuf); ! varnamebuf = NULL; varnamebuflen = 0; return NULL; } --- 3204,3210 ---- if (vidx < VV_LEN) return cat_prefix_varname('v', (char_u *)vimvars[vidx++].vv_name); ! VIM_CLEAR(varnamebuf); varnamebuflen = 0; return NULL; } *************** *** 6096,6105 **** /* next try expanding things like $VIM and ${HOME} */ string = expand_env_save(name - 1); if (string != NULL && *string == '$') ! { ! vim_free(string); ! string = NULL; ! } } name[len] = cc; --- 6086,6092 ---- /* next try expanding things like $VIM and ${HOME} */ string = expand_env_save(name - 1); if (string != NULL && *string == '$') ! VIM_CLEAR(string); } name[len] = cc; *************** *** 7116,7123 **** func_unref(varp->vval.v_string); /* FALLTHROUGH */ case VAR_STRING: ! vim_free(varp->vval.v_string); ! varp->vval.v_string = NULL; break; case VAR_PARTIAL: partial_unref(varp->vval.v_partial); --- 7103,7109 ---- func_unref(varp->vval.v_string); /* FALLTHROUGH */ case VAR_STRING: ! VIM_CLEAR(varp->vval.v_string); break; case VAR_PARTIAL: partial_unref(varp->vval.v_partial); *** ../vim-8.0.1495/src/evalfunc.c 2018-02-10 15:38:31.026211917 +0100 --- src/evalfunc.c 2018-02-10 18:34:22.877553065 +0100 *************** *** 9222,9231 **** if (*q != NUL) STRMOVE(remain, q - 1); else ! { ! vim_free(remain); ! remain = NULL; ! } } /* If the result is a relative path name, make it explicitly relative to --- 9222,9228 ---- if (*q != NUL) STRMOVE(remain, q - 1); else ! VIM_CLEAR(remain); } /* If the result is a relative path name, make it explicitly relative to *** ../vim-8.0.1495/src/ex_cmds.c 2018-02-03 18:33:13.052705544 +0100 --- src/ex_cmds.c 2018-02-10 18:34:22.877553065 +0100 *************** *** 1957,1964 **** if (!shortname && st_new.st_dev == st_old.st_dev && st_new.st_ino == st_old.st_ino) { ! vim_free(tempname); ! tempname = NULL; shortname = TRUE; break; } --- 1957,1963 ---- if (!shortname && st_new.st_dev == st_old.st_dev && st_new.st_ino == st_old.st_ino) { ! VIM_CLEAR(tempname); shortname = TRUE; break; } *************** *** 5225,5232 **** lnum += regmatch.startpos[0].lnum; sub_firstlnum += regmatch.startpos[0].lnum; nmatch -= regmatch.startpos[0].lnum; ! vim_free(sub_firstline); ! sub_firstline = NULL; } if (sub_firstline == NULL) --- 5224,5230 ---- lnum += regmatch.startpos[0].lnum; sub_firstlnum += regmatch.startpos[0].lnum; nmatch -= regmatch.startpos[0].lnum; ! VIM_CLEAR(sub_firstline); } if (sub_firstline == NULL) *************** *** 5388,5397 **** sub_firstline + copycol); if (new_line == NULL) ! { ! vim_free(orig_line); ! orig_line = NULL; ! } else { /* Position the cursor relative to the --- 5386,5392 ---- sub_firstline + copycol); if (new_line == NULL) ! VIM_CLEAR(orig_line); else { /* Position the cursor relative to the *************** *** 5820,5827 **** if (did_sub) ++sub_nlines; vim_free(new_start); /* for when substitute was cancelled */ ! vim_free(sub_firstline); /* free the copy of the original line */ ! sub_firstline = NULL; } line_breakcheck(); --- 5815,5821 ---- if (did_sub) ++sub_nlines; vim_free(new_start); /* for when substitute was cancelled */ ! VIM_CLEAR(sub_firstline); /* free the copy of the original line */ } line_breakcheck(); *************** *** 6975,6982 **** && fnamecmp(e1, fname + 4) != 0) { /* Not .txt and not .abx, remove it. */ ! vim_free(fnames[i1]); ! fnames[i1] = NULL; continue; } if (e1 - f1 != e2 - f2 --- 6969,6975 ---- && fnamecmp(e1, fname + 4) != 0) { /* Not .txt and not .abx, remove it. */ ! VIM_CLEAR(fnames[i1]); continue; } if (e1 - f1 != e2 - f2 *************** *** 6984,6994 **** continue; if (fnamecmp(e1, ".txt") == 0 && fnamecmp(e2, fname + 4) == 0) - { /* use .abx instead of .txt */ ! vim_free(fnames[i1]); ! fnames[i1] = NULL; ! } } } #endif --- 6977,6984 ---- continue; if (fnamecmp(e1, ".txt") == 0 && fnamecmp(e2, fname + 4) == 0) /* use .abx instead of .txt */ ! VIM_CLEAR(fnames[i1]); } } #endif *** ../vim-8.0.1495/src/ex_cmds2.c 2018-02-04 17:47:37.929909714 +0100 --- src/ex_cmds2.c 2018-02-10 18:34:22.877553065 +0100 *************** *** 1298,1304 **** if (this_due <= 1) { bevalexpr_due_set = FALSE; - if (balloonEval == NULL) { balloonEval = (BalloonEval *)alloc(sizeof(BalloonEval)); --- 1298,1303 ---- *************** *** 5489,5496 **** { for (i = 0; locales[i] != NULL; i++) vim_free(locales[i]); ! vim_free(locales); ! locales = NULL; } } # endif --- 5488,5494 ---- { for (i = 0; locales[i] != NULL; i++) vim_free(locales[i]); ! VIM_CLEAR(locales); } } # endif *** ../vim-8.0.1495/src/ex_docmd.c 2018-02-09 17:50:24.614970413 +0100 --- src/ex_docmd.c 2018-02-10 18:34:22.881553037 +0100 *************** *** 868,875 **** { /* Each '|' separated command is stored separately in lines_ga, to * be able to jump to it. Don't use next_cmdline now. */ ! vim_free(cmdline_copy); ! cmdline_copy = NULL; /* Check if a function has returned or, unless it has an unclosed * try conditional, aborted. */ --- 868,874 ---- { /* Each '|' separated command is stored separately in lines_ga, to * be able to jump to it. Don't use next_cmdline now. */ ! VIM_CLEAR(cmdline_copy); /* Check if a function has returned or, unless it has an unclosed * try conditional, aborted. */ *************** *** 1084,1091 **** if (next_cmdline == NULL) { ! vim_free(cmdline_copy); ! cmdline_copy = NULL; #ifdef FEAT_CMDHIST /* * If the command was typed, remember it for the ':' register. --- 1083,1089 ---- if (next_cmdline == NULL) { ! VIM_CLEAR(cmdline_copy); #ifdef FEAT_CMDHIST /* * If the command was typed, remember it for the ':' register. *************** *** 5802,5812 **** goto fail; } ! vim_free(cmd->uc_rep); ! cmd->uc_rep = NULL; #if defined(FEAT_EVAL) && defined(FEAT_CMDL_COMPL) ! vim_free(cmd->uc_compl_arg); ! cmd->uc_compl_arg = NULL; #endif break; } --- 5800,5808 ---- goto fail; } ! VIM_CLEAR(cmd->uc_rep); #if defined(FEAT_EVAL) && defined(FEAT_CMDL_COMPL) ! VIM_CLEAR(cmd->uc_compl_arg); #endif break; } *************** *** 8952,8962 **** void free_cd_dir(void) { ! vim_free(prev_dir); ! prev_dir = NULL; ! ! vim_free(globaldir); ! globaldir = NULL; } #endif --- 8948,8955 ---- void free_cd_dir(void) { ! VIM_CLEAR(prev_dir); ! VIM_CLEAR(globaldir); } #endif *************** *** 8967,8974 **** void post_chdir(int local) { ! vim_free(curwin->w_localdir); ! curwin->w_localdir = NULL; if (local) { /* If still in global directory, need to remember current --- 8960,8966 ---- void post_chdir(int local) { ! VIM_CLEAR(curwin->w_localdir); if (local) { /* If still in global directory, need to remember current *************** *** 8983,8990 **** { /* We are now in the global directory, no need to remember its * name. */ ! vim_free(globaldir); ! globaldir = NULL; } shorten_fnames(TRUE); --- 8975,8981 ---- { /* We are now in the global directory, no need to remember its * name. */ ! VIM_CLEAR(globaldir); } shorten_fnames(TRUE); *** ../vim-8.0.1495/src/ex_getln.c 2018-01-31 15:48:01.101171621 +0100 --- src/ex_getln.c 2018-02-10 18:34:22.881553037 +0100 *************** *** 164,171 **** static void abandon_cmdline(void) { ! vim_free(ccline.cmdbuff); ! ccline.cmdbuff = NULL; if (msg_scrolled == 0) compute_cmdrow(); MSG(""); --- 164,170 ---- static void abandon_cmdline(void) { ! VIM_CLEAR(ccline.cmdbuff); if (msg_scrolled == 0) compute_cmdrow(); MSG(""); *************** *** 500,509 **** && c != K_KPAGEDOWN && c != K_KPAGEUP && c != K_LEFT && c != K_RIGHT && (xpc.xp_numfiles > 0 || (c != Ctrl_P && c != Ctrl_N))) ! { ! vim_free(lookfor); ! lookfor = NULL; ! } #endif /* --- 499,505 ---- && c != K_KPAGEDOWN && c != K_KPAGEUP && c != K_LEFT && c != K_RIGHT && (xpc.xp_numfiles > 0 || (c != Ctrl_P && c != Ctrl_N))) ! VIM_CLEAR(lookfor); #endif /* *************** *** 1096,1103 **** ) goto cmdline_not_changed; ! vim_free(ccline.cmdbuff); /* no commandline to return */ ! ccline.cmdbuff = NULL; if (!cmd_silent) { #ifdef FEAT_RIGHTLEFT --- 1092,1098 ---- ) goto cmdline_not_changed; ! VIM_CLEAR(ccline.cmdbuff); /* no commandline to return */ if (!cmd_silent) { #ifdef FEAT_RIGHTLEFT *************** *** 3683,3692 **** || ccline.cmdbuff[i + j] == '?') break; if ((int)STRLEN(p2) < j) ! { ! vim_free(p2); ! p2 = NULL; ! } } } } --- 3678,3684 ---- || ccline.cmdbuff[i + j] == '?') break; if ((int)STRLEN(p2) < j) ! VIM_CLEAR(p2); } } } *************** *** 3832,3839 **** { FreeWild(xp->xp_numfiles, xp->xp_files); xp->xp_numfiles = -1; ! vim_free(orig_save); ! orig_save = NULL; } findex = 0; --- 3824,3830 ---- { FreeWild(xp->xp_numfiles, xp->xp_files); xp->xp_numfiles = -1; ! VIM_CLEAR(orig_save); } findex = 0; *************** *** 6737,6744 **** else concat_history(type); ! vim_free(viminfo_history[type]); ! viminfo_history[type] = NULL; viminfo_hisidx[type] = 0; } } --- 6728,6734 ---- else concat_history(type); ! VIM_CLEAR(viminfo_history[type]); viminfo_hisidx[type] = 0; } } *************** *** 6862,6869 **** for (i = 0; i < viminfo_hisidx[type]; ++i) if (viminfo_history[type] != NULL) vim_free(viminfo_history[type][i].hisstr); ! vim_free(viminfo_history[type]); ! viminfo_history[type] = NULL; viminfo_hisidx[type] = 0; } } --- 6852,6858 ---- for (i = 0; i < viminfo_hisidx[type]; ++i) if (viminfo_history[type] != NULL) vim_free(viminfo_history[type][i].hisstr); ! VIM_CLEAR(viminfo_history[type]); viminfo_hisidx[type] = 0; } } *** ../vim-8.0.1495/src/fileio.c 2018-02-10 18:15:00.758098776 +0100 --- src/fileio.c 2018-02-10 18:34:22.881553037 +0100 *************** *** 1073,1080 **** if (tmpname != NULL) { mch_remove(tmpname); /* delete converted file */ ! vim_free(tmpname); ! tmpname = NULL; } } --- 1073,1079 ---- if (tmpname != NULL) { mch_remove(tmpname); /* delete converted file */ ! VIM_CLEAR(tmpname); } } *************** *** 2602,2609 **** #endif msg_add_lines(c, (long)linecnt, filesize); ! vim_free(keep_msg); ! keep_msg = NULL; msg_scrolled_ign = TRUE; #ifdef ALWAYS_USE_GUI /* Don't show the message when reading stdin, it would end up in a --- 2601,2607 ---- #endif msg_add_lines(c, (long)linecnt, filesize); ! VIM_CLEAR(keep_msg); msg_scrolled_ign = TRUE; #ifdef ALWAYS_USE_GUI /* Don't show the message when reading stdin, it would end up in a *************** *** 2955,2962 **** if (tmpname != NULL) { mch_remove(tmpname); /* delete converted file */ ! vim_free(tmpname); ! tmpname = NULL; } } --- 2953,2959 ---- if (tmpname != NULL) { mch_remove(tmpname); /* delete converted file */ ! VIM_CLEAR(tmpname); } } *************** *** 3945,3952 **** if (st_new.st_dev == st_old.st_dev && st_new.st_ino == st_old.st_ino) { ! vim_free(backup); ! backup = NULL; /* no backup file to delete */ /* * may try again with 'shortname' set */ --- 3942,3948 ---- if (st_new.st_dev == st_old.st_dev && st_new.st_ino == st_old.st_ino) { ! VIM_CLEAR(backup); /* no backup file to delete */ /* * may try again with 'shortname' set */ *************** *** 3980,3989 **** --*wp; /* They all exist??? Must be something wrong. */ if (*wp == 'a') ! { ! vim_free(backup); ! backup = NULL; ! } } } break; --- 3976,3982 ---- --*wp; /* They all exist??? Must be something wrong. */ if (*wp == 'a') ! VIM_CLEAR(backup); } } break; *************** *** 4010,4019 **** (void)umask(umask_save); #endif if (bfd < 0) ! { ! vim_free(backup); ! backup = NULL; ! } else { /* Set file protection same as original file, but --- 4003,4009 ---- (void)umask(umask_save); #endif if (bfd < 0) ! VIM_CLEAR(backup); else { /* Set file protection same as original file, but *************** *** 4156,4165 **** --*p; /* They all exist??? Must be something wrong! */ if (*p == 'a') ! { ! vim_free(backup); ! backup = NULL; ! } } } if (backup != NULL) --- 4146,4152 ---- --*p; /* They all exist??? Must be something wrong! */ if (*p == 'a') ! VIM_CLEAR(backup); } } if (backup != NULL) *************** *** 4177,4184 **** if (vim_rename(fname, backup) == 0) break; ! vim_free(backup); /* don't do the rename below */ ! backup = NULL; } } if (backup == NULL && !forceit) --- 4164,4170 ---- if (vim_rename(fname, backup) == 0) break; ! VIM_CLEAR(backup); /* don't do the rename below */ } } if (backup == NULL && !forceit) *************** *** 5079,5086 **** else if (mch_stat(org, &st) < 0) { vim_rename(backup, (char_u *)org); ! vim_free(backup); /* don't delete the file */ ! backup = NULL; #ifdef UNIX set_file_time((char_u *)org, st_old.st_atime, st_old.st_mtime); #endif --- 5065,5071 ---- else if (mch_stat(org, &st) < 0) { vim_rename(backup, (char_u *)org); ! VIM_CLEAR(backup); /* don't delete the file */ #ifdef UNIX set_file_time((char_u *)org, st_old.st_atime, st_old.st_mtime); #endif *************** *** 6227,6234 **** || buf->b_sfname == NULL || mch_isFullName(buf->b_sfname))) { ! vim_free(buf->b_sfname); ! buf->b_sfname = NULL; p = shorten_fname(buf->b_ffname, dirname); if (p != NULL) { --- 6212,6218 ---- || buf->b_sfname == NULL || mch_isFullName(buf->b_sfname))) { ! VIM_CLEAR(buf->b_sfname); p = shorten_fname(buf->b_ffname, dirname); if (p != NULL) { *************** *** 7427,7434 **** /* remove the trailing path separator */ gettail(vim_tempdir)[-1] = NUL; delete_recursive(vim_tempdir); ! vim_free(vim_tempdir); ! vim_tempdir = NULL; } } --- 7411,7417 ---- /* remove the trailing path separator */ gettail(vim_tempdir)[-1] = NUL; delete_recursive(vim_tempdir); ! VIM_CLEAR(vim_tempdir); } } *************** *** 8018,8025 **** static void au_remove_pat(AutoPat *ap) { ! vim_free(ap->pat); ! ap->pat = NULL; ap->buflocal_nr = -1; au_need_clean = TRUE; } --- 8001,8007 ---- static void au_remove_pat(AutoPat *ap) { ! VIM_CLEAR(ap->pat); ap->buflocal_nr = -1; au_need_clean = TRUE; } *************** *** 8033,8042 **** AutoCmd *ac; for (ac = ap->cmds; ac != NULL; ac = ac->next) ! { ! vim_free(ac->cmd); ! ac->cmd = NULL; ! } au_need_clean = TRUE; } --- 8015,8021 ---- AutoCmd *ac; for (ac = ap->cmds; ac != NULL; ac = ac->next) ! VIM_CLEAR(ac->cmd); au_need_clean = TRUE; } *************** *** 9094,9101 **** /* Make sure w_localdir and globaldir are NULL to avoid a chdir() in * win_enter_ext(). */ ! vim_free(aucmd_win->w_localdir); ! aucmd_win->w_localdir = NULL; aco->globaldir = globaldir; globaldir = NULL; --- 9073,9079 ---- /* Make sure w_localdir and globaldir are NULL to avoid a chdir() in * win_enter_ext(). */ ! VIM_CLEAR(aucmd_win->w_localdir); aco->globaldir = globaldir; globaldir = NULL; *************** *** 9877,9884 **** char_u *name; char *s; ! vim_free(sourcing_name); ! sourcing_name = NULL; for (ap = apc->curpat; ap != NULL && !got_int; ap = ap->next) { --- 9855,9861 ---- char_u *name; char *s; ! VIM_CLEAR(sourcing_name); for (ap = apc->curpat; ap != NULL && !got_int; ap = ap->next) { *************** *** 10561,10568 **** EMSG(_("E219: Missing {.")); else EMSG(_("E220: Missing }.")); ! vim_free(reg_pat); ! reg_pat = NULL; } return reg_pat; } --- 10538,10544 ---- EMSG(_("E219: Missing {.")); else EMSG(_("E220: Missing }.")); ! VIM_CLEAR(reg_pat); } return reg_pat; } *** ../vim-8.0.1495/src/gui_gtk_x11.c 2018-01-31 21:09:57.635847521 +0100 --- src/gui_gtk_x11.c 2018-02-10 18:34:22.885553009 +0100 *************** *** 3838,3845 **** # endif } #endif ! vim_free(gui_argv); ! gui_argv = NULL; #if GLIB_CHECK_VERSION(2,1,3) /* Set the human-readable application name */ --- 3838,3844 ---- # endif } #endif ! VIM_CLEAR(gui_argv); #if GLIB_CHECK_VERSION(2,1,3) /* Set the human-readable application name */ *************** *** 4668,4675 **** y += hh - pixel_height; gtk_window_move(GTK_WINDOW(gui.mainwin), x, y); } ! vim_free(gui.geom); ! gui.geom = NULL; /* From now until everyone's stopped trying to set the window hints * to their correct minimum values, stop them being set as we need --- 4667,4673 ---- y += hh - pixel_height; gtk_window_move(GTK_WINDOW(gui.mainwin), x, y); } ! VIM_CLEAR(gui.geom); /* From now until everyone's stopped trying to set the window hints * to their correct minimum values, stop them being set as we need *** ../vim-8.0.1495/src/gui_photon.c 2018-01-31 21:09:57.639847489 +0100 --- src/gui_photon.c 2018-02-10 18:34:22.885553009 +0100 *************** *** 1040,1047 **** PtSetResource(gui.vimPanelGroup, Pt_ARG_PG_PANEL_TITLES, &empty_title, 1); ! vim_free(panel_titles); ! panel_titles = NULL; } } --- 1040,1046 ---- PtSetResource(gui.vimPanelGroup, Pt_ARG_PG_PANEL_TITLES, &empty_title, 1); ! VIM_CLEAR(panel_titles); } } *** ../vim-8.0.1495/src/gui_w32.c 2018-01-31 21:09:57.639847489 +0100 --- src/gui_w32.c 2018-02-10 18:34:22.885553009 +0100 *************** *** 4941,4948 **** char_u *str = NULL; static void *tt_text = NULL; ! vim_free(tt_text); ! tt_text = NULL; # ifdef FEAT_GUI_TABLINE if (gui_mch_showing_tabline() --- 4941,4947 ---- char_u *str = NULL; static void *tt_text = NULL; ! VIM_CLEAR(tt_text); # ifdef FEAT_GUI_TABLINE if (gui_mch_showing_tabline() *** ../vim-8.0.1495/src/gui_x11.c 2018-01-31 21:09:57.643847455 +0100 --- src/gui_x11.c 2018-02-10 18:34:22.885553009 +0100 *************** *** 826,832 **** # endif ) { ! int maxlen = len * 4 + 40; /* guessed */ char_u *p = (char_u *)XtMalloc(maxlen); mch_memmove(p, string, len); --- 826,832 ---- # endif ) { ! int maxlen = len * 4 + 40; /* guessed */ char_u *p = (char_u *)XtMalloc(maxlen); mch_memmove(p, string, len); *************** *** 1567,1574 **** XtCloseDisplay(gui.dpy); gui.dpy = NULL; vimShell = (Widget)0; ! vim_free(gui_argv); ! gui_argv = NULL; } /* --- 1567,1573 ---- XtCloseDisplay(gui.dpy); gui.dpy = NULL; vimShell = (Widget)0; ! VIM_CLEAR(gui_argv); } /* *************** *** 1741,1748 **** * says that this isn't needed when exiting, so just skip it. */ XtCloseDisplay(gui.dpy); #endif ! vim_free(gui_argv); ! gui_argv = NULL; } /* --- 1740,1746 ---- * says that this isn't needed when exiting, so just skip it. */ XtCloseDisplay(gui.dpy); #endif ! VIM_CLEAR(gui_argv); } /* *************** *** 1956,1962 **** { XFontStruct *font; ! if (!gui.in_use || name == NULL) /* can't do this when GUI not running */ return NOFONT; font = XLoadQueryFont(gui.dpy, (char *)name); --- 1954,1960 ---- { XFontStruct *font; ! if (!gui.in_use || name == NULL) /* can't do this when GUI not running */ return NOFONT; font = XLoadQueryFont(gui.dpy, (char *)name); *************** *** 2275,2281 **** guicolor_T gui_mch_get_color(char_u *name) { ! guicolor_T requested; /* can't do this when GUI not running */ if (!gui.in_use || name == NULL || *name == NUL) --- 2273,2279 ---- guicolor_T gui_mch_get_color(char_u *name) { ! guicolor_T requested; /* can't do this when GUI not running */ if (!gui.in_use || name == NULL || *name == NUL) *************** *** 2298,2305 **** guicolor_T gui_mch_get_rgb_color(int r, int g, int b) { ! char spec[8]; /* space enough to hold "#RRGGBB" */ ! XColor available; Colormap colormap; vim_snprintf(spec, sizeof(spec), "#%.2x%.2x%.2x", r, g, b); --- 2296,2303 ---- guicolor_T gui_mch_get_rgb_color(int r, int g, int b) { ! char spec[8]; /* space enough to hold "#RRGGBB" */ ! XColor available; Colormap colormap; vim_snprintf(spec, sizeof(spec), "#%.2x%.2x%.2x", r, g, b); *** ../vim-8.0.1495/src/hardcopy.c 2017-03-16 17:23:26.823815869 +0100 --- src/hardcopy.c 2018-02-10 18:34:22.885553009 +0100 *************** *** 2210,2217 **** for (i = PRT_PS_FONT_ROMAN; i <= PRT_PS_FONT_BOLDOBLIQUE; i++) { if (prt_ps_mb_font.ps_fontname[i] != NULL) ! vim_free(prt_ps_mb_font.ps_fontname[i]); ! prt_ps_mb_font.ps_fontname[i] = NULL; } } --- 2210,2216 ---- for (i = PRT_PS_FONT_ROMAN; i <= PRT_PS_FONT_BOLDOBLIQUE; i++) { if (prt_ps_mb_font.ps_fontname[i] != NULL) ! VIM_CLEAR(prt_ps_mb_font.ps_fontname[i]); } } *************** *** 2228,2237 **** prt_file_error = FALSE; } if (prt_ps_file_name != NULL) ! { ! vim_free(prt_ps_file_name); ! prt_ps_file_name = NULL; ! } } static float --- 2227,2233 ---- prt_file_error = FALSE; } if (prt_ps_file_name != NULL) ! VIM_CLEAR(prt_ps_file_name); } static float *** ../vim-8.0.1495/src/if_cscope.c 2018-01-30 22:52:01.262625576 +0100 --- src/if_cscope.c 2018-02-10 18:34:22.885553009 +0100 *************** *** 1479,1486 **** { if ((csinfo[i].ppath = (char *)alloc((unsigned)strlen(ppath) + 1)) == NULL) { ! vim_free(csinfo[i].fname); ! csinfo[i].fname = NULL; return -1; } (void)strcpy(csinfo[i].ppath, (const char *)ppath); --- 1479,1485 ---- { if ((csinfo[i].ppath = (char *)alloc((unsigned)strlen(ppath) + 1)) == NULL) { ! VIM_CLEAR(csinfo[i].fname); return -1; } (void)strcpy(csinfo[i].ppath, (const char *)ppath); *************** *** 1491,1500 **** { if ((csinfo[i].flags = (char *)alloc((unsigned)strlen(flags) + 1)) == NULL) { ! vim_free(csinfo[i].fname); ! vim_free(csinfo[i].ppath); ! csinfo[i].fname = NULL; ! csinfo[i].ppath = NULL; return -1; } (void)strcpy(csinfo[i].flags, (const char *)flags); --- 1490,1497 ---- { if ((csinfo[i].flags = (char *)alloc((unsigned)strlen(flags) + 1)) == NULL) { ! VIM_CLEAR(csinfo[i].fname); ! VIM_CLEAR(csinfo[i].ppath); return -1; } (void)strcpy(csinfo[i].flags, (const char *)flags); *************** *** 1939,1948 **** if (totsofar == 0) { /* No matches, free the arrays and return NULL in "*matches_p". */ ! vim_free(matches); ! matches = NULL; ! vim_free(cntxts); ! cntxts = NULL; } *matched = totsofar; *matches_p = matches; --- 1936,1943 ---- if (totsofar == 0) { /* No matches, free the arrays and return NULL in "*matches_p". */ ! VIM_CLEAR(matches); ! VIM_CLEAR(cntxts); } *matched = totsofar; *matches_p = matches; *************** *** 2445,2451 **** if (csdir != NULL) { vim_strncpy(csdir, (char_u *)csinfo[i].fname, ! gettail((char_u *)csinfo[i].fname) - (char_u *)csinfo[i].fname); len += (int)STRLEN(csdir); } --- 2440,2446 ---- if (csdir != NULL) { vim_strncpy(csdir, (char_u *)csinfo[i].fname, ! gettail((char_u *)csinfo[i].fname) - (char_u *)csinfo[i].fname); len += (int)STRLEN(csdir); } *** ../vim-8.0.1495/src/macros.h 2018-01-31 20:51:40.305835913 +0100 --- src/macros.h 2018-02-10 18:34:22.885553009 +0100 *************** *** 379,381 **** --- 379,392 ---- # define mch_enable_flush() # define mch_disable_flush() #endif + + /* + * Like vim_free(), and also set the pointer to NULL. + */ + #define VIM_CLEAR(p) \ + do { \ + if ((p) != NULL) { \ + vim_free(p); \ + (p) = NULL; \ + } \ + } while (0) *** ../vim-8.0.1495/src/main.c 2018-02-10 18:15:00.758098776 +0100 --- src/main.c 2018-02-10 18:34:22.885553009 +0100 *************** *** 3951,3958 **** { /* Output error from remote */ mch_errmsg((char *)res); ! vim_free(res); ! res = NULL; } mch_errmsg(_(": Send expression failed.\n")); } --- 3951,3957 ---- { /* Output error from remote */ mch_errmsg((char *)res); ! VIM_CLEAR(res); } mch_errmsg(_(": Send expression failed.\n")); } *** ../vim-8.0.1495/src/mark.c 2017-09-16 20:54:47.106560363 +0200 --- src/mark.c 2018-02-10 18:34:22.885553009 +0100 *************** *** 127,134 **** i = c - 'A'; namedfm[i].fmark.mark = *pos; namedfm[i].fmark.fnum = fnum; ! vim_free(namedfm[i].fname); ! namedfm[i].fname = NULL; #ifdef FEAT_VIMINFO namedfm[i].time_set = vim_time(); #endif --- 127,133 ---- i = c - 'A'; namedfm[i].fmark.mark = *pos; namedfm[i].fmark.fnum = fnum; ! VIM_CLEAR(namedfm[i].fname); #ifdef FEAT_VIMINFO namedfm[i].time_set = vim_time(); #endif *************** *** 598,605 **** && fnamecmp(name, fm->fname) == 0) { fm->fmark.fnum = buf->b_fnum; ! vim_free(fm->fname); ! fm->fname = NULL; } } --- 597,603 ---- && fnamecmp(name, fm->fname) == 0) { fm->fmark.fnum = buf->b_fnum; ! VIM_CLEAR(fm->fname); } } *************** *** 862,869 **** else n = i - 'A'; namedfm[n].fmark.mark.lnum = 0; ! vim_free(namedfm[n].fname); ! namedfm[n].fname = NULL; #ifdef FEAT_VIMINFO namedfm[n].time_set = 0; #endif --- 860,866 ---- else n = i - 'A'; namedfm[n].fmark.mark.lnum = 0; ! VIM_CLEAR(namedfm[n].fname); #ifdef FEAT_VIMINFO namedfm[n].time_set = 0; #endif *************** *** 1480,1495 **** { for (i = 0; i < NMARKS + EXTRA_MARKS; ++i) vim_free(vi_namedfm[i].fname); ! vim_free(vi_namedfm); ! vi_namedfm = NULL; } #ifdef FEAT_JUMPLIST if (vi_jumplist != NULL) { for (i = 0; i < vi_jumplist_len; ++i) vim_free(vi_jumplist[i].fname); ! vim_free(vi_jumplist); ! vi_jumplist = NULL; } #endif } --- 1477,1490 ---- { for (i = 0; i < NMARKS + EXTRA_MARKS; ++i) vim_free(vi_namedfm[i].fname); ! VIM_CLEAR(vi_namedfm); } #ifdef FEAT_JUMPLIST if (vi_jumplist != NULL) { for (i = 0; i < vi_jumplist_len; ++i) vim_free(vi_jumplist[i].fname); ! VIM_CLEAR(vi_jumplist); } #endif } *** ../vim-8.0.1495/src/mbyte.c 2018-01-27 21:01:30.242242117 +0100 --- src/mbyte.c 2018-02-10 18:34:22.889552979 +0100 *************** *** 4666,4673 **** else if (ICONV_ERRNO != ICONV_E2BIG) { /* conversion failed */ ! vim_free(result); ! result = NULL; break; } /* Not enough room or skipping illegal sequence. */ --- 4666,4672 ---- else if (ICONV_ERRNO != ICONV_E2BIG) { /* conversion failed */ ! VIM_CLEAR(result); break; } /* Not enough room or skipping illegal sequence. */ *** ../vim-8.0.1495/src/memfile.c 2016-11-10 20:01:41.193582919 +0100 --- src/memfile.c 2018-02-10 18:34:22.889552979 +0100 *************** *** 297,306 **** if (mfp->mf_fname != NULL) { mch_remove(mfp->mf_fname); /* delete the swap file */ ! vim_free(mfp->mf_fname); ! vim_free(mfp->mf_ffname); ! mfp->mf_fname = NULL; ! mfp->mf_ffname = NULL; } } --- 297,304 ---- if (mfp->mf_fname != NULL) { mch_remove(mfp->mf_fname); /* delete the swap file */ ! VIM_CLEAR(mfp->mf_fname); ! VIM_CLEAR(mfp->mf_ffname); } } *************** *** 1288,1297 **** */ if (mfp->mf_fd < 0) { ! vim_free(mfp->mf_fname); ! vim_free(mfp->mf_ffname); ! mfp->mf_fname = NULL; ! mfp->mf_ffname = NULL; } else { --- 1286,1293 ---- */ if (mfp->mf_fd < 0) { ! VIM_CLEAR(mfp->mf_fname); ! VIM_CLEAR(mfp->mf_ffname); } else { *** ../vim-8.0.1495/src/memline.c 2017-12-02 15:11:18.417655196 +0100 --- src/memline.c 2018-02-10 18:34:22.889552979 +0100 *************** *** 535,542 **** idx = 0; /* start with first index in block 1 */ error = 0; buf->b_ml.ml_stack_top = 0; ! vim_free(buf->b_ml.ml_stack); ! buf->b_ml.ml_stack = NULL; buf->b_ml.ml_stack_size = 0; /* no stack yet */ for ( ; !got_int; line_breakcheck()) --- 535,541 ---- idx = 0; /* start with first index in block 1 */ error = 0; buf->b_ml.ml_stack_top = 0; ! VIM_CLEAR(buf->b_ml.ml_stack); buf->b_ml.ml_stack_size = 0; /* no stack yet */ for ( ; !got_int; line_breakcheck()) *************** *** 852,859 **** vim_free(buf->b_ml.ml_line_ptr); vim_free(buf->b_ml.ml_stack); #ifdef FEAT_BYTEOFF ! vim_free(buf->b_ml.ml_chunksize); ! buf->b_ml.ml_chunksize = NULL; #endif buf->b_ml.ml_mfp = NULL; --- 851,857 ---- vim_free(buf->b_ml.ml_line_ptr); vim_free(buf->b_ml.ml_stack); #ifdef FEAT_BYTEOFF ! VIM_CLEAR(buf->b_ml.ml_chunksize); #endif buf->b_ml.ml_mfp = NULL; *************** *** 4197,4204 **** break; if ((n = (int)STRLEN(fname)) == 0) /* safety check */ { ! vim_free(fname); ! fname = NULL; break; } #if defined(UNIX) --- 4195,4201 ---- break; if ((n = (int)STRLEN(fname)) == 0) /* safety check */ { ! VIM_CLEAR(fname); break; } #if defined(UNIX) *************** *** 4578,4585 **** if (fname[n - 2] == 'a') /* ".saa": tried enough, give up */ { EMSG(_("E326: Too many swap files found")); ! vim_free(fname); ! fname = NULL; break; } --fname[n - 2]; /* ".svz", ".suz", etc. */ --- 4575,4581 ---- if (fname[n - 2] == 'a') /* ".saa": tried enough, give up */ { EMSG(_("E326: Too many swap files found")); ! VIM_CLEAR(fname); break; } --fname[n - 2]; /* ".svz", ".suz", etc. */ *** ../vim-8.0.1495/src/menu.c 2017-11-18 22:13:04.745908763 +0100 --- src/menu.c 2018-02-10 18:34:22.889552979 +0100 *************** *** 727,734 **** menup = &menu->children; parent = menu; name = next_name; ! vim_free(dname); ! dname = NULL; if (pri_tab[pri_idx + 1] != -1) ++pri_idx; } --- 727,733 ---- menup = &menu->children; parent = menu; name = next_name; ! VIM_CLEAR(dname); if (pri_tab[pri_idx + 1] != -1) ++pri_idx; } *** ../vim-8.0.1495/src/message.c 2018-02-04 16:38:41.751315295 +0100 --- src/message.c 2018-02-10 18:34:22.889552979 +0100 *************** *** 415,422 **** void reset_last_sourcing(void) { ! vim_free(last_sourcing_name); ! last_sourcing_name = NULL; last_sourcing_lnum = 0; } --- 415,421 ---- void reset_last_sourcing(void) { ! VIM_CLEAR(last_sourcing_name); last_sourcing_lnum = 0; } *************** *** 1249,1258 **** reset_last_sourcing(); if (keep_msg != NULL && vim_strsize(keep_msg) >= (Rows - cmdline_row - 1) * Columns + sc_col) ! { ! vim_free(keep_msg); ! keep_msg = NULL; /* don't redisplay message, it's too long */ ! } if (tmpState == SETWSIZE) /* got resize event while in vgetc() */ { --- 1248,1254 ---- reset_last_sourcing(); if (keep_msg != NULL && vim_strsize(keep_msg) >= (Rows - cmdline_row - 1) * Columns + sc_col) ! VIM_CLEAR(keep_msg); /* don't redisplay message, it's too long */ if (tmpState == SETWSIZE) /* got resize event while in vgetc() */ { *************** *** 1325,1334 **** int did_return = FALSE; if (!msg_silent) ! { ! vim_free(keep_msg); ! keep_msg = NULL; /* don't display old message now */ ! } #ifdef FEAT_EVAL if (need_clr_eos) --- 1321,1327 ---- int did_return = FALSE; if (!msg_silent) ! VIM_CLEAR(keep_msg); #ifdef FEAT_EVAL if (need_clr_eos) *************** *** 3481,3488 **** #ifdef FEAT_EVAL set_vim_var_string(VV_WARNINGMSG, message, -1); #endif ! vim_free(keep_msg); ! keep_msg = NULL; if (hl) keep_msg_attr = HL_ATTR(HLF_W); else --- 3474,3480 ---- #ifdef FEAT_EVAL set_vim_var_string(VV_WARNINGMSG, message, -1); #endif ! VIM_CLEAR(keep_msg); if (hl) keep_msg_attr = HL_ATTR(HLF_W); else *** ../vim-8.0.1495/src/misc1.c 2018-02-04 16:38:41.751315295 +0100 --- src/misc1.c 2018-02-10 18:34:22.889552979 +0100 *************** *** 3745,3752 **** char_u *var; /* In case we are called a second time (when 'encoding' changes). */ ! vim_free(homedir); ! homedir = NULL; #ifdef VMS var = mch_getenv((char_u *)"SYS$LOGIN"); --- 3745,3751 ---- char_u *var; /* In case we are called a second time (when 'encoding' changes). */ ! VIM_CLEAR(homedir); #ifdef VMS var = mch_getenv((char_u *)"SYS$LOGIN"); *************** *** 4358,4367 **** p = vim_strnsave(p, (int)(pend - p)); if (p != NULL && !mch_isdir(p)) ! { ! vim_free(p); ! p = NULL; ! } else { #ifdef USE_EXE_NAME --- 4357,4363 ---- p = vim_strnsave(p, (int)(pend - p)); if (p != NULL && !mch_isdir(p)) ! VIM_CLEAR(p); else { #ifdef USE_EXE_NAME *************** *** 9775,9782 **** /* If the number of matches is now zero, we fail. */ if (*num_files == 0) { ! vim_free(*files); ! *files = NULL; return FAIL; } } --- 9771,9777 ---- /* If the number of matches is now zero, we fail. */ if (*num_files == 0) { ! VIM_CLEAR(*files); return FAIL; } } *************** *** 10031,10040 **** hFind = FindFirstFileW(wn, &wfb); if (hFind == INVALID_HANDLE_VALUE && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) ! { ! vim_free(wn); ! wn = NULL; ! } } } --- 10026,10032 ---- hFind = FindFirstFileW(wn, &wfb); if (hFind == INVALID_HANDLE_VALUE && GetLastError() == ERROR_CALL_NOT_IMPLEMENTED) ! VIM_CLEAR(wn); } } *************** *** 10122,10129 **** # endif hFind = FindFirstFile((LPCSTR)buf, &fb); ok = (hFind != INVALID_HANDLE_VALUE); ! vim_free(matchname); ! matchname = NULL; } } --- 10114,10120 ---- # endif hFind = FindFirstFile((LPCSTR)buf, &fb); ok = (hFind != INVALID_HANDLE_VALUE); ! VIM_CLEAR(matchname); } } *************** *** 11256,11263 **** if (i != len) { EMSG2(_(e_notread), tempname); ! vim_free(buffer); ! buffer = NULL; } else if (ret_len == NULL) { --- 11247,11253 ---- if (i != len) { EMSG2(_(e_notread), tempname); ! VIM_CLEAR(buffer); } else if (ret_len == NULL) { *** ../vim-8.0.1495/src/misc2.c 2018-02-10 15:38:31.022211945 +0100 --- src/misc2.c 2018-02-10 18:34:22.889552979 +0100 *************** *** 1827,1832 **** --- 1827,1834 ---- * Replacement for free() that ignores NULL pointers. * Also skip free() when exiting for sure, this helps when we caught a deadly * signal that was caused by a crash in free(). + * If you want to set NULL after calling this function, you should use + * VIM_CLEAR() instead. */ void vim_free(void *x) *************** *** 1840,1858 **** } } - /* - * Like vim_free(), and also set the pointer to NULL. - */ - void - vim_clear(void **x) - { - if (*x != NULL) - { - vim_free(*x); - *x = NULL; - } - } - #ifndef HAVE_MEMSET void * vim_memset(void *ptr, int c, size_t size) --- 1842,1847 ---- *** ../vim-8.0.1495/src/netbeans.c 2018-02-03 17:36:22.630091837 +0100 --- src/netbeans.c 2018-02-10 18:34:22.893552951 +0100 *************** *** 580,587 **** buf.bufp->b_was_netbeans_file = FALSE; } } ! vim_free(buf_list); ! buf_list = NULL; buf_list_size = 0; buf_list_used = 0; --- 580,586 ---- buf.bufp->b_was_netbeans_file = FALSE; } } ! VIM_CLEAR(buf_list); buf_list_size = 0; buf_list_used = 0; *************** *** 1477,1484 **** EMSG("E636: invalid buffer identifier in create"); return FAIL; } ! vim_free(buf->displayname); ! buf->displayname = NULL; netbeansReadFile = 0; /* don't try to open disk file */ do_ecmd(0, NULL, 0, 0, ECMD_ONE, ECMD_HIDE + ECMD_OLDBUF, curwin); --- 1476,1482 ---- EMSG("E636: invalid buffer identifier in create"); return FAIL; } ! VIM_CLEAR(buf->displayname); netbeansReadFile = 0; /* don't try to open disk file */ do_ecmd(0, NULL, 0, 0, ECMD_ONE, ECMD_HIDE + ECMD_OLDBUF, curwin); *************** *** 3447,3454 **** msg_add_lines(c, (long)lnum, nchars); /* Now display it */ ! vim_free(keep_msg); ! keep_msg = NULL; msg_scrolled_ign = TRUE; msg_trunc_attr(IObuff, FALSE, 0); msg_scrolled_ign = FALSE; --- 3445,3451 ---- msg_add_lines(c, (long)lnum, nchars); /* Now display it */ ! VIM_CLEAR(keep_msg); msg_scrolled_ign = TRUE; msg_trunc_attr(IObuff, FALSE, 0); msg_scrolled_ign = FALSE; *************** *** 3475,3482 **** msg_add_lines(c, buf->bufp->b_ml.ml_line_count, buf->bufp->b_orig_size); ! vim_free(keep_msg); ! keep_msg = NULL; msg_scrolled_ign = TRUE; p = msg_trunc_attr(IObuff, FALSE, 0); if ((msg_scrolled && !need_wait_return) || !buf->initDone) --- 3472,3478 ---- msg_add_lines(c, buf->bufp->b_ml.ml_line_count, buf->bufp->b_orig_size); ! VIM_CLEAR(keep_msg); msg_scrolled_ign = TRUE; p = msg_trunc_attr(IObuff, FALSE, 0); if ((msg_scrolled && !need_wait_return) || !buf->initDone) *** ../vim-8.0.1495/src/normal.c 2018-02-06 22:52:45.706103329 +0100 --- src/normal.c 2018-02-10 18:34:22.893552951 +0100 *************** *** 1482,1489 **** { AppendToRedobuffLit(repeat_cmdline, -1); AppendToRedobuff(NL_STR); ! vim_free(repeat_cmdline); ! repeat_cmdline = NULL; } } } --- 1482,1488 ---- { AppendToRedobuffLit(repeat_cmdline, -1); AppendToRedobuff(NL_STR); ! VIM_CLEAR(repeat_cmdline); } } } *** ../vim-8.0.1495/src/ops.c 2018-02-06 22:52:45.706103329 +0100 --- src/ops.c 2018-02-10 18:34:22.893552951 +0100 *************** *** 1235,1242 **** EMSG(_(e_nolastcmd)); return FAIL; } ! vim_free(new_last_cmdline); /* don't keep the cmdline containing @: */ ! new_last_cmdline = NULL; /* Escape all control characters with a CTRL-V */ p = vim_strsave_escaped_ext(last_cmdline, (char_u *)"\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037", Ctrl_V, FALSE); --- 1235,1241 ---- EMSG(_(e_nolastcmd)); return FAIL; } ! VIM_CLEAR(new_last_cmdline); /* don't keep the cmdline containing @: */ /* Escape all control characters with a CTRL-V */ p = vim_strsave_escaped_ext(last_cmdline, (char_u *)"\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037", Ctrl_V, FALSE); *************** *** 2995,3002 **** #endif vim_free(y_current->y_array[i]); } ! vim_free(y_current->y_array); ! y_current->y_array = NULL; #ifdef AMIGA if (n >= 1000) MSG(""); --- 2994,3000 ---- #endif vim_free(y_current->y_array[i]); } ! VIM_CLEAR(y_current->y_array); #ifdef AMIGA if (n >= 1000) MSG(""); *************** *** 6040,6047 **** vim_free(y_read_regs[i].y_array[j]); vim_free(y_read_regs[i].y_array); } ! vim_free(y_read_regs); ! y_read_regs = NULL; } } --- 6038,6044 ---- vim_free(y_read_regs[i].y_array[j]); vim_free(y_read_regs[i].y_array); } ! VIM_CLEAR(y_read_regs); } } *************** *** 7146,7153 **** /* Without any lines make the register empty. */ if (y_ptr->y_size + newlines == 0) { ! vim_free(y_ptr->y_array); ! y_ptr->y_array = NULL; return; } --- 7143,7149 ---- /* Without any lines make the register empty. */ if (y_ptr->y_size + newlines == 0) { ! VIM_CLEAR(y_ptr->y_array); return; } *** ../vim-8.0.1495/src/option.c 2018-02-10 18:28:48.187960299 +0100 --- src/option.c 2018-02-10 18:34:22.893552951 +0100 *************** *** 11735,11742 **** if (buf == NULL) { ! vim_free(*file); ! *file = NULL; return FAIL; } --- 11735,11741 ---- if (buf == NULL) { ! VIM_CLEAR(*file); return FAIL; } *** ../vim-8.0.1495/src/os_amiga.c 2017-03-12 19:22:31.760584901 +0100 --- src/os_amiga.c 2018-02-10 18:34:22.893552951 +0100 *************** *** 1619,1626 **** else #endif { ! vim_free(alloced); ! alloced = NULL; retval = NULL; buf = alloc(IOSIZE); --- 1619,1625 ---- else #endif { ! VIM_CLEAR(alloced); retval = NULL; buf = alloc(IOSIZE); *** ../vim-8.0.1495/src/os_mac_conv.c 2017-11-18 23:22:56.646328040 +0100 --- src/os_mac_conv.c 2018-02-10 18:34:22.893552951 +0100 *************** *** 480,489 **** if (TECConvertText(gPathConverter, decompPath, decompLen, &decompLen, result, decompLen, &actualLen) != noErr) ! { ! vim_free(result); ! result = NULL; ! } } } --- 480,486 ---- if (TECConvertText(gPathConverter, decompPath, decompLen, &decompLen, result, decompLen, &actualLen) != noErr) ! VIM_CLEAR(result); } } *************** *** 517,526 **** utf8_len += inputRead; } else ! { ! vim_free(result); ! result = NULL; ! } } else { --- 514,520 ---- utf8_len += inputRead; } else ! VIM_CLEAR(result); } else { *** ../vim-8.0.1495/src/os_mswin.c 2017-08-11 20:55:49.024419841 +0200 --- src/os_mswin.c 2018-02-10 18:34:22.897552921 +0100 *************** *** 1233,1240 **** if (prt_name != NULL) { vimSetDlgItemText(hDlg, IDC_PRINTTEXT2, (char_u *)prt_name); ! vim_free(prt_name); ! prt_name = NULL; } EnableMenuItem(GetSystemMenu(hDlg, FALSE), SC_CLOSE, MF_GRAYED); #ifndef FEAT_GUI --- 1233,1239 ---- if (prt_name != NULL) { vimSetDlgItemText(hDlg, IDC_PRINTTEXT2, (char_u *)prt_name); ! VIM_CLEAR(prt_name); } EnableMenuItem(GetSystemMenu(hDlg, FALSE), SC_CLOSE, MF_GRAYED); #ifndef FEAT_GUI *************** *** 2608,2613 **** --- 2607,2613 ---- while (reply_received == 0) { #ifdef FEAT_TIMERS + /* TODO: use the return value to decide how long to wait. */ check_due_timer(); #endif time(&now); *** ../vim-8.0.1495/src/os_unix.c 2017-12-18 18:14:43.455768463 +0100 --- src/os_unix.c 2018-02-10 18:34:22.897552921 +0100 *************** *** 371,377 **** #endif /* ! * Write s[len] to the screen. */ void mch_write(char_u *s, int len) --- 371,377 ---- #endif /* ! * Write s[len] to the screen (stdout). */ void mch_write(char_u *s, int len) *************** *** 1311,1318 **** /* * Set oldtitle to NULL, so the current title is obtained again. */ ! vim_free(oldtitle); ! oldtitle = NULL; # endif settmode(TMODE_RAW); need_check_timestamps = TRUE; --- 1311,1317 ---- /* * Set oldtitle to NULL, so the current title is obtained again. */ ! VIM_CLEAR(oldtitle); # endif settmode(TMODE_RAW); need_check_timestamps = TRUE; *************** *** 3261,3268 **** XCloseDisplay(x11_display); # endif # if defined(HAVE_SIGALTSTACK) || defined(HAVE_SIGSTACK) ! vim_free(signal_stack); ! signal_stack = NULL; # endif # ifdef FEAT_TITLE vim_free(oldtitle); --- 3260,3266 ---- XCloseDisplay(x11_display); # endif # if defined(HAVE_SIGALTSTACK) || defined(HAVE_SIGSTACK) ! VIM_CLEAR(signal_stack); # endif # ifdef FEAT_TITLE vim_free(oldtitle); *************** *** 6765,6772 **** if (*num_file == 0) /* rejected all entries */ { ! vim_free(*file); ! *file = NULL; goto notfound; } --- 6763,6769 ---- if (*num_file == 0) /* rejected all entries */ { ! VIM_CLEAR(*file); goto notfound; } *** ../vim-8.0.1495/src/os_win32.c 2018-02-03 17:36:22.634091794 +0100 --- src/os_win32.c 2018-02-10 18:34:22.897552921 +0100 *************** *** 2252,2259 **** cb->Regions = (PSMALL_RECT)alloc(cb->NumRegions * sizeof(SMALL_RECT)); if (cb->Regions == NULL) { ! vim_free(cb->Buffer); ! cb->Buffer = NULL; return FALSE; } } --- 2252,2258 ---- cb->Regions = (PSMALL_RECT)alloc(cb->NumRegions * sizeof(SMALL_RECT)); if (cb->Regions == NULL) { ! VIM_CLEAR(cb->Buffer); return FALSE; } } *************** *** 2278,2287 **** BufferCoord, /* offset in our buffer */ &ReadRegion)) /* region to save */ { ! vim_free(cb->Buffer); ! cb->Buffer = NULL; ! vim_free(cb->Regions); ! cb->Regions = NULL; return FALSE; } cb->Regions[i] = ReadRegion; --- 2277,2284 ---- BufferCoord, /* offset in our buffer */ &ReadRegion)) /* region to save */ { ! VIM_CLEAR(cb->Buffer); ! VIM_CLEAR(cb->Regions); return FALSE; } cb->Regions[i] = ReadRegion; *** ../vim-8.0.1495/src/popupmnu.c 2018-02-10 18:28:48.183960328 +0100 --- src/popupmnu.c 2018-02-10 18:34:22.897552921 +0100 *************** *** 975,982 **** pum_undisplay(); while (balloon_arraysize > 0) vim_free(balloon_array[--balloon_arraysize].pum_text); ! vim_free(balloon_array); ! balloon_array = NULL; } } --- 975,981 ---- pum_undisplay(); while (balloon_arraysize > 0) vim_free(balloon_array[--balloon_arraysize].pum_text); ! VIM_CLEAR(balloon_array); } } *** ../vim-8.0.1495/src/proto/misc2.pro 2018-02-09 12:29:52.335647866 +0100 --- src/proto/misc2.pro 2018-02-10 18:34:41.461419935 +0100 *************** *** 46,52 **** void vim_strcat(char_u *to, char_u *from, size_t tosize); int copy_option_part(char_u **option, char_u *buf, int maxlen, char *sep_chars); void vim_free(void *x); - void vim_clear(void **x); int vim_stricmp(char *s1, char *s2); int vim_strnicmp(char *s1, char *s2, size_t len); char_u *vim_strchr(char_u *string, int c); --- 46,51 ---- *** ../vim-8.0.1495/src/quickfix.c 2018-01-27 11:52:08.713774824 +0100 --- src/quickfix.c 2018-02-10 18:34:41.465419906 +0100 *************** *** 1177,1184 **** int status; /* Do not used the cached buffer, it may have been wiped out. */ ! vim_free(qf_last_bufname); ! qf_last_bufname = NULL; vim_memset(&state, 0, sizeof(state)); vim_memset(&fields, 0, sizeof(fields)); --- 1177,1183 ---- int status; /* Do not used the cached buffer, it may have been wiped out. */ ! VIM_CLEAR(qf_last_bufname); vim_memset(&state, 0, sizeof(state)); vim_memset(&fields, 0, sizeof(fields)); *************** *** 1229,1236 **** if (last_efm == NULL || (STRCMP(last_efm, efm) != 0)) { /* free the previously parsed data */ ! vim_free(last_efm); ! last_efm = NULL; free_efm_list(&fmt_first); /* parse the current 'efm' */ --- 1228,1234 ---- if (last_efm == NULL || (STRCMP(last_efm, efm) != 0)) { /* free the previously parsed data */ ! VIM_CLEAR(last_efm); free_efm_list(&fmt_first); /* parse the current 'efm' */ *************** *** 1351,1358 **** static void qf_store_title(qf_info_T *qi, int qf_idx, char_u *title) { ! vim_free(qi->qf_lists[qf_idx].qf_title); ! qi->qf_lists[qf_idx].qf_title = NULL; if (title != NULL) { --- 1349,1355 ---- static void qf_store_title(qf_info_T *qi, int qf_idx, char_u *title) { ! VIM_CLEAR(qi->qf_lists[qf_idx].qf_title); if (title != NULL) { *************** *** 3003,3010 **** qf_free_items(qi, idx); ! vim_free(qfl->qf_title); ! qfl->qf_title = NULL; free_tv(qfl->qf_ctx); qfl->qf_ctx = NULL; qfl->qf_id = 0; --- 3000,3006 ---- qf_free_items(qi, idx); ! VIM_CLEAR(qfl->qf_title); free_tv(qfl->qf_ctx); qfl->qf_ctx = NULL; qfl->qf_id = 0; *** ../vim-8.0.1495/src/regexp.c 2017-11-02 22:29:32.840234120 +0100 --- src/regexp.c 2018-02-10 18:34:41.465419906 +0100 *************** *** 3996,4005 **** /* Free "reg_tofree" when it's a bit big. * Free regstack and backpos if they are bigger than their initial size. */ if (reg_tofreelen > 400) ! { ! vim_free(reg_tofree); ! reg_tofree = NULL; ! } if (regstack.ga_maxlen > REGSTACK_INITIAL) ga_clear(®stack); if (backpos.ga_maxlen > BACKPOS_INITIAL) --- 3996,4002 ---- /* Free "reg_tofree" when it's a bit big. * Free regstack and backpos if they are bigger than their initial size. */ if (reg_tofreelen > 400) ! VIM_CLEAR(reg_tofree); if (regstack.ga_maxlen > REGSTACK_INITIAL) ga_clear(®stack); if (backpos.ga_maxlen > BACKPOS_INITIAL) *************** *** 7521,7528 **** { STRCPY(dest, eval_result); dst += STRLEN(eval_result); ! vim_free(eval_result); ! eval_result = NULL; } } else --- 7518,7524 ---- { STRCPY(dest, eval_result); dst += STRLEN(eval_result); ! VIM_CLEAR(eval_result); } } else *************** *** 8150,8156 **** * First try the NFA engine, unless backtracking was requested. */ if (regexp_engine != BACKTRACKING_ENGINE) ! prog = nfa_regengine.regcomp(expr, re_flags + (regexp_engine == AUTOMATIC_ENGINE ? RE_AUTO : 0)); else prog = bt_regengine.regcomp(expr, re_flags); --- 8146,8152 ---- * First try the NFA engine, unless backtracking was requested. */ if (regexp_engine != BACKTRACKING_ENGINE) ! prog = nfa_regengine.regcomp(expr, re_flags + (regexp_engine == AUTOMATIC_ENGINE ? RE_AUTO : 0)); else prog = bt_regengine.regcomp(expr, re_flags); *************** *** 8170,8176 **** } else EMSG2("(NFA) Could not open \"%s\" to write !!!", ! BT_REGEXP_DEBUG_LOG_NAME); } #endif /* --- 8166,8172 ---- } else EMSG2("(NFA) Could not open \"%s\" to write !!!", ! BT_REGEXP_DEBUG_LOG_NAME); } #endif /* *************** *** 8341,8350 **** long vim_regexec_multi( regmmatch_T *rmp, ! win_T *win, /* window in which to search or NULL */ ! buf_T *buf, /* buffer in which to search */ ! linenr_T lnum, /* nr of line to start looking for match */ ! colnr_T col, /* column to start looking for match */ proftime_T *tm, /* timeout limit or NULL */ int *timed_out) /* flag is set when timeout limit reached */ { --- 8337,8346 ---- long vim_regexec_multi( regmmatch_T *rmp, ! win_T *win, /* window in which to search or NULL */ ! buf_T *buf, /* buffer in which to search */ ! linenr_T lnum, /* nr of line to start looking for match */ ! colnr_T col, /* column to start looking for match */ proftime_T *tm, /* timeout limit or NULL */ int *timed_out) /* flag is set when timeout limit reached */ { *** ../vim-8.0.1495/src/regexp_nfa.c 2018-02-08 22:45:13.115323597 +0100 --- src/regexp_nfa.c 2018-02-10 18:34:41.465419906 +0100 *************** *** 7334,7347 **** nfa_regengine.expr = NULL; out: ! vim_free(post_start); ! post_start = post_ptr = post_end = NULL; state_ptr = NULL; return (regprog_T *)prog; fail: ! vim_free(prog); ! prog = NULL; #ifdef ENABLE_LOG nfa_postfix_dump(expr, FAIL); #endif --- 7334,7346 ---- nfa_regengine.expr = NULL; out: ! VIM_CLEAR(post_start); ! post_ptr = post_end = NULL; state_ptr = NULL; return (regprog_T *)prog; fail: ! VIM_CLEAR(prog); #ifdef ENABLE_LOG nfa_postfix_dump(expr, FAIL); #endif *** ../vim-8.0.1495/src/screen.c 2018-02-08 09:57:23.803488891 +0100 --- src/screen.c 2018-02-10 18:34:41.469419878 +0100 *************** *** 4326,4335 **** #endif if (p_extra_free != NULL) ! { ! vim_free(p_extra_free); ! p_extra_free = NULL; ! } /* * Get a character from the line itself. */ --- 4326,4332 ---- #endif if (p_extra_free != NULL) ! VIM_CLEAR(p_extra_free); /* * Get a character from the line itself. */ *************** *** 8860,8886 **** * and over again. */ done_outofmem_msg = TRUE; } ! vim_free(new_ScreenLines); ! new_ScreenLines = NULL; #ifdef FEAT_MBYTE ! vim_free(new_ScreenLinesUC); ! new_ScreenLinesUC = NULL; for (i = 0; i < p_mco; ++i) ! { ! vim_free(new_ScreenLinesC[i]); ! new_ScreenLinesC[i] = NULL; ! } ! vim_free(new_ScreenLines2); ! new_ScreenLines2 = NULL; #endif ! vim_free(new_ScreenAttrs); ! new_ScreenAttrs = NULL; ! vim_free(new_LineOffset); ! new_LineOffset = NULL; ! vim_free(new_LineWraps); ! new_LineWraps = NULL; ! vim_free(new_TabPageIdxs); ! new_TabPageIdxs = NULL; } else { --- 8857,8873 ---- * and over again. */ done_outofmem_msg = TRUE; } ! VIM_CLEAR(new_ScreenLines); #ifdef FEAT_MBYTE ! VIM_CLEAR(new_ScreenLinesUC); for (i = 0; i < p_mco; ++i) ! VIM_CLEAR(new_ScreenLinesC[i]); ! VIM_CLEAR(new_ScreenLines2); #endif ! VIM_CLEAR(new_ScreenAttrs); ! VIM_CLEAR(new_LineOffset); ! VIM_CLEAR(new_LineWraps); ! VIM_CLEAR(new_TabPageIdxs); } else { *** ../vim-8.0.1495/src/search.c 2018-02-09 19:23:57.018446646 +0100 --- src/search.c 2018-02-10 18:34:41.469419878 +0100 *************** *** 5059,5066 **** prev_fname = NULL; } } ! vim_free(new_fname); ! new_fname = NULL; already_searched = TRUE; break; } --- 5059,5065 ---- prev_fname = NULL; } } ! VIM_CLEAR(new_fname); already_searched = TRUE; break; } *** ../vim-8.0.1495/src/spell.c 2017-10-24 21:49:32.234837736 +0200 --- src/spell.c 2018-02-10 18:34:41.473419848 +0100 *************** *** 1994,2012 **** int i; int round; ! vim_free(lp->sl_fbyts); ! lp->sl_fbyts = NULL; ! vim_free(lp->sl_kbyts); ! lp->sl_kbyts = NULL; ! vim_free(lp->sl_pbyts); ! lp->sl_pbyts = NULL; ! ! vim_free(lp->sl_fidxs); ! lp->sl_fidxs = NULL; ! vim_free(lp->sl_kidxs); ! lp->sl_kidxs = NULL; ! vim_free(lp->sl_pidxs); ! lp->sl_pidxs = NULL; for (round = 1; round <= 2; ++round) { --- 1994,2006 ---- int i; int round; ! VIM_CLEAR(lp->sl_fbyts); ! VIM_CLEAR(lp->sl_kbyts); ! VIM_CLEAR(lp->sl_pbyts); ! ! VIM_CLEAR(lp->sl_fidxs); ! VIM_CLEAR(lp->sl_kidxs); ! VIM_CLEAR(lp->sl_pidxs); for (round = 1; round <= 2; ++round) { *************** *** 2048,2073 **** for (i = 0; i < lp->sl_prefixcnt; ++i) vim_regfree(lp->sl_prefprog[i]); lp->sl_prefixcnt = 0; ! vim_free(lp->sl_prefprog); ! lp->sl_prefprog = NULL; ! vim_free(lp->sl_info); ! lp->sl_info = NULL; ! vim_free(lp->sl_midword); ! lp->sl_midword = NULL; vim_regfree(lp->sl_compprog); - vim_free(lp->sl_comprules); - vim_free(lp->sl_compstartflags); - vim_free(lp->sl_compallflags); lp->sl_compprog = NULL; ! lp->sl_comprules = NULL; ! lp->sl_compstartflags = NULL; ! lp->sl_compallflags = NULL; ! vim_free(lp->sl_syllable); ! lp->sl_syllable = NULL; ga_clear(&lp->sl_syl_items); ga_clear_strings(&lp->sl_comppat); --- 2042,2060 ---- for (i = 0; i < lp->sl_prefixcnt; ++i) vim_regfree(lp->sl_prefprog[i]); lp->sl_prefixcnt = 0; ! VIM_CLEAR(lp->sl_prefprog); ! VIM_CLEAR(lp->sl_info); ! VIM_CLEAR(lp->sl_midword); vim_regfree(lp->sl_compprog); lp->sl_compprog = NULL; ! VIM_CLEAR(lp->sl_comprules); ! VIM_CLEAR(lp->sl_compstartflags); ! VIM_CLEAR(lp->sl_compallflags); ! VIM_CLEAR(lp->sl_syllable); ga_clear(&lp->sl_syl_items); ga_clear_strings(&lp->sl_comppat); *************** *** 2094,2103 **** void slang_clear_sug(slang_T *lp) { ! vim_free(lp->sl_sbyts); ! lp->sl_sbyts = NULL; ! vim_free(lp->sl_sidxs); ! lp->sl_sidxs = NULL; close_spellbuf(lp->sl_sugbuf); lp->sl_sugbuf = NULL; lp->sl_sugloaded = FALSE; --- 2081,2088 ---- void slang_clear_sug(slang_T *lp) { ! VIM_CLEAR(lp->sl_sbyts); ! VIM_CLEAR(lp->sl_sidxs); close_spellbuf(lp->sl_sugbuf); lp->sl_sugbuf = NULL; lp->sl_sugloaded = FALSE; *************** *** 2671,2678 **** { vim_memset(wp->w_s->b_spell_ismw, 0, 256); #ifdef FEAT_MBYTE ! vim_free(wp->w_s->b_spell_ismw_mb); ! wp->w_s->b_spell_ismw_mb = NULL; #endif } --- 2656,2662 ---- { vim_memset(wp->w_s->b_spell_ismw, 0, 256); #ifdef FEAT_MBYTE ! VIM_CLEAR(wp->w_s->b_spell_ismw_mb); #endif } *************** *** 2859,2866 **** mch_remove(int_wordlist); int_wordlist_spl(fname); mch_remove(fname); ! vim_free(int_wordlist); ! int_wordlist = NULL; } } --- 2843,2849 ---- mch_remove(int_wordlist); int_wordlist_spl(fname); mch_remove(fname); ! VIM_CLEAR(int_wordlist); } } *************** *** 2887,2896 **** spell_delete_wordlist(); ! vim_free(repl_to); ! repl_to = NULL; ! vim_free(repl_from); ! repl_from = NULL; } #endif --- 2870,2877 ---- spell_delete_wordlist(); ! VIM_CLEAR(repl_to); ! VIM_CLEAR(repl_from); } #endif *************** *** 3425,3434 **** } else { ! vim_free(repl_from); ! repl_from = NULL; ! vim_free(repl_to); ! repl_to = NULL; #ifdef FEAT_RIGHTLEFT /* When 'rightleft' is set the list is drawn right-left. */ --- 3406,3413 ---- } else { ! VIM_CLEAR(repl_from); ! VIM_CLEAR(repl_to); #ifdef FEAT_RIGHTLEFT /* When 'rightleft' is set the list is drawn right-left. */ *** ../vim-8.0.1495/src/spellfile.c 2018-02-10 14:12:39.202145763 +0100 --- src/spellfile.c 2018-02-10 18:34:41.473419848 +0100 *************** *** 1352,1359 **** { if (c == '?' || c == '+' || c == '*') { ! vim_free(slang->sl_comprules); ! slang->sl_comprules = NULL; crp = NULL; } else --- 1352,1358 ---- { if (c == '?' || c == '+' || c == '*') { ! VIM_CLEAR(slang->sl_comprules); crp = NULL; } else *** ../vim-8.0.1495/src/syntax.c 2017-12-01 21:07:16.224989882 +0100 --- src/syntax.c 2018-02-10 18:34:41.473419848 +0100 *************** *** 1189,1196 **** { for (p = block->b_sst_first; p != NULL; p = p->sst_next) clear_syn_state(p); ! vim_free(block->b_sst_array); ! block->b_sst_array = NULL; block->b_sst_len = 0; } } --- 1189,1195 ---- { for (p = block->b_sst_first; p != NULL; p = p->sst_next) clear_syn_state(p); ! VIM_CLEAR(block->b_sst_array); block->b_sst_len = 0; } } *************** *** 2134,2140 **** r = syn_regexec(®match, current_lnum, (colnr_T)lc_col, ! IF_SYN_TIME(&spp->sp_time)); spp->sp_prog = regmatch.regprog; if (!r) { --- 2133,2139 ---- r = syn_regexec(®match, current_lnum, (colnr_T)lc_col, ! IF_SYN_TIME(&spp->sp_time)); spp->sp_prog = regmatch.regprog; if (!r) { *************** *** 3641,3648 **** vim_regfree(block->b_syn_linecont_prog); block->b_syn_linecont_prog = NULL; ! vim_free(block->b_syn_linecont_pat); ! block->b_syn_linecont_pat = NULL; #ifdef FEAT_FOLDING block->b_syn_folditems = 0; #endif --- 3640,3646 ---- vim_regfree(block->b_syn_linecont_prog); block->b_syn_linecont_prog = NULL; ! VIM_CLEAR(block->b_syn_linecont_pat); #ifdef FEAT_FOLDING block->b_syn_folditems = 0; #endif *************** *** 3690,3697 **** vim_regfree(curwin->w_s->b_syn_linecont_prog); curwin->w_s->b_syn_linecont_prog = NULL; ! vim_free(curwin->w_s->b_syn_linecont_pat); ! curwin->w_s->b_syn_linecont_pat = NULL; clear_string_option(&curwin->w_s->b_syn_isk); syn_stack_free_all(curwin->w_s); /* Need to recompute all syntax. */ --- 3688,3694 ---- vim_regfree(curwin->w_s->b_syn_linecont_prog); curwin->w_s->b_syn_linecont_prog = NULL; ! VIM_CLEAR(curwin->w_s->b_syn_linecont_pat); clear_string_option(&curwin->w_s->b_syn_isk); syn_stack_free_all(curwin->w_s); /* Need to recompute all syntax. */ *************** *** 3810,3817 **** */ short scl_id = id - SYNID_CLUSTER; ! vim_free(SYN_CLSTR(curwin->w_s)[scl_id].scl_list); ! SYN_CLSTR(curwin->w_s)[scl_id].scl_list = NULL; } } else --- 3807,3813 ---- */ short scl_id = id - SYNID_CLUSTER; ! VIM_CLEAR(SYN_CLSTR(curwin->w_s)[scl_id].scl_list); } } else *************** *** 5954,5961 **** if (curwin->w_s->b_syn_linecont_prog == NULL) { ! vim_free(curwin->w_s->b_syn_linecont_pat); ! curwin->w_s->b_syn_linecont_pat = NULL; finished = TRUE; break; } --- 5950,5956 ---- if (curwin->w_s->b_syn_linecont_prog == NULL) { ! VIM_CLEAR(curwin->w_s->b_syn_linecont_pat); finished = TRUE; break; } *************** *** 8369,8378 **** HL_TABLE()[idx].sg_cleared = TRUE; HL_TABLE()[idx].sg_term = 0; ! vim_free(HL_TABLE()[idx].sg_start); ! HL_TABLE()[idx].sg_start = NULL; ! vim_free(HL_TABLE()[idx].sg_stop); ! HL_TABLE()[idx].sg_stop = NULL; HL_TABLE()[idx].sg_term_attr = 0; HL_TABLE()[idx].sg_cterm = 0; HL_TABLE()[idx].sg_cterm_bold = FALSE; --- 8364,8371 ---- HL_TABLE()[idx].sg_cleared = TRUE; HL_TABLE()[idx].sg_term = 0; ! VIM_CLEAR(HL_TABLE()[idx].sg_start); ! VIM_CLEAR(HL_TABLE()[idx].sg_stop); HL_TABLE()[idx].sg_term_attr = 0; HL_TABLE()[idx].sg_cterm = 0; HL_TABLE()[idx].sg_cterm_bold = FALSE; *************** *** 8381,8392 **** HL_TABLE()[idx].sg_cterm_attr = 0; #if defined(FEAT_GUI) || defined(FEAT_EVAL) HL_TABLE()[idx].sg_gui = 0; ! vim_free(HL_TABLE()[idx].sg_gui_fg_name); ! HL_TABLE()[idx].sg_gui_fg_name = NULL; ! vim_free(HL_TABLE()[idx].sg_gui_bg_name); ! HL_TABLE()[idx].sg_gui_bg_name = NULL; ! vim_free(HL_TABLE()[idx].sg_gui_sp_name); ! HL_TABLE()[idx].sg_gui_sp_name = NULL; #endif #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) HL_TABLE()[idx].sg_gui_fg = INVALCOLOR; --- 8374,8382 ---- HL_TABLE()[idx].sg_cterm_attr = 0; #if defined(FEAT_GUI) || defined(FEAT_EVAL) HL_TABLE()[idx].sg_gui = 0; ! VIM_CLEAR(HL_TABLE()[idx].sg_gui_fg_name); ! VIM_CLEAR(HL_TABLE()[idx].sg_gui_bg_name); ! VIM_CLEAR(HL_TABLE()[idx].sg_gui_sp_name); #endif #if defined(FEAT_GUI) || defined(FEAT_TERMGUICOLORS) HL_TABLE()[idx].sg_gui_fg = INVALCOLOR; *************** *** 8400,8407 **** gui_mch_free_fontset(HL_TABLE()[idx].sg_fontset); HL_TABLE()[idx].sg_fontset = NOFONTSET; # endif ! vim_free(HL_TABLE()[idx].sg_font_name); ! HL_TABLE()[idx].sg_font_name = NULL; HL_TABLE()[idx].sg_gui_attr = 0; #endif #ifdef FEAT_EVAL --- 8390,8396 ---- gui_mch_free_fontset(HL_TABLE()[idx].sg_fontset); HL_TABLE()[idx].sg_fontset = NOFONTSET; # endif ! VIM_CLEAR(HL_TABLE()[idx].sg_font_name); HL_TABLE()[idx].sg_gui_attr = 0; #endif #ifdef FEAT_EVAL *** ../vim-8.0.1495/src/tag.c 2018-02-09 19:25:24.209735206 +0100 --- src/tag.c 2018-02-10 18:34:41.473419848 +0100 *************** *** 1091,1098 **** void tag_freematch(void) { ! vim_free(tagmatchname); ! tagmatchname = NULL; } static void --- 1091,1097 ---- void tag_freematch(void) { ! VIM_CLEAR(tagmatchname); } static void *************** *** 2620,2629 **** # if defined(FEAT_QUICKFIX) if (ptag_entry.tagname) ! { ! vim_free(ptag_entry.tagname); ! ptag_entry.tagname = NULL; ! } # endif } #endif --- 2619,2625 ---- # if defined(FEAT_QUICKFIX) if (ptag_entry.tagname) ! VIM_CLEAR(ptag_entry.tagname); # endif } #endif *** ../vim-8.0.1495/src/term.c 2018-01-31 20:51:40.309835870 +0100 --- src/term.c 2018-02-10 18:34:41.477419820 +0100 *************** *** 2502,2508 **** } /* ! * out_flush_cursor(): flush the output buffer and redraw the cursor */ void out_flush_cursor( --- 2502,2509 ---- } /* ! * out_flush_cursor(): flush the output buffer and redraw the cursor. ! * Does not flush recursively in the GUI to avoid slow drawing. */ void out_flush_cursor( *************** *** 3912,3919 **** { while (tc_len > 0) vim_free(termcodes[--tc_len].code); ! vim_free(termcodes); ! termcodes = NULL; tc_max_len = 0; #ifdef HAVE_TGETENT --- 3913,3919 ---- { while (tc_len > 0) vim_free(termcodes[--tc_len].code); ! VIM_CLEAR(termcodes); tc_max_len = 0; #ifdef HAVE_TGETENT *************** *** 5648,5654 **** /* Work out our pseudo mouse event. Note that MOUSE_RELEASE gets * added, then it's not mouse up/down. */ key_name[0] = (int)KS_EXTRA; ! if (wheel_code != 0 && (wheel_code & MOUSE_RELEASE) != MOUSE_RELEASE) { if (wheel_code & MOUSE_CTRL) --- 5648,5654 ---- /* Work out our pseudo mouse event. Note that MOUSE_RELEASE gets * added, then it's not mouse up/down. */ key_name[0] = (int)KS_EXTRA; ! if (wheel_code != 0 && (wheel_code & MOUSE_RELEASE) != MOUSE_RELEASE) { if (wheel_code & MOUSE_CTRL) *** ../vim-8.0.1495/src/terminal.c 2018-02-09 16:45:56.045258620 +0100 --- src/terminal.c 2018-02-10 18:34:41.477419820 +0100 *************** *** 1176,1183 **** set_terminal_mode(term_T *term, int normal_mode) { term->tl_normal_mode = normal_mode; ! vim_free(term->tl_status_text); ! term->tl_status_text = NULL; if (term->tl_buffer == curbuf) maketitle(); } --- 1176,1182 ---- set_terminal_mode(term_T *term, int normal_mode) { term->tl_normal_mode = normal_mode; ! VIM_CLEAR(term->tl_status_text); if (term->tl_buffer == curbuf) maketitle(); } *************** *** 1739,1748 **** for (term = first_term; term != NULL; term = term->tl_next) if (term->tl_job == job) { ! vim_free(term->tl_title); ! term->tl_title = NULL; ! vim_free(term->tl_status_text); ! term->tl_status_text = NULL; redraw_buf_and_status_later(term->tl_buffer, VALID); did_one = TRUE; } --- 1738,1745 ---- for (term = first_term; term != NULL; term = term->tl_next) if (term->tl_job == job) { ! VIM_CLEAR(term->tl_title); ! VIM_CLEAR(term->tl_status_text); redraw_buf_and_status_later(term->tl_buffer, VALID); did_one = TRUE; } *************** *** 2023,2030 **** #endif else term->tl_title = vim_strsave((char_u *)value->string); ! vim_free(term->tl_status_text); ! term->tl_status_text = NULL; if (term == curbuf->b_term) maketitle(); break; --- 2020,2026 ---- #endif else term->tl_title = vim_strsave((char_u *)value->string); ! VIM_CLEAR(term->tl_status_text); if (term == curbuf->b_term) maketitle(); break; *************** *** 2189,2198 **** term->tl_channel_closed = TRUE; did_one = TRUE; ! vim_free(term->tl_title); ! term->tl_title = NULL; ! vim_free(term->tl_status_text); ! term->tl_status_text = NULL; /* Unless in Terminal-Normal mode: clear the vterm. */ if (!term->tl_normal_mode) --- 2185,2192 ---- term->tl_channel_closed = TRUE; did_one = TRUE; ! VIM_CLEAR(term->tl_title); ! VIM_CLEAR(term->tl_status_text); /* Unless in Terminal-Normal mode: clear the vterm. */ if (!term->tl_normal_mode) *** ../vim-8.0.1495/src/ui.c 2018-01-31 20:51:40.309835870 +0100 --- src/ui.c 2018-02-10 18:34:41.477419820 +0100 *************** *** 130,137 **** if (maxlen >= ta_len - ta_off) { mch_memmove(buf, ta_str + ta_off, (size_t)ta_len); ! vim_free(ta_str); ! ta_str = NULL; return ta_len; } mch_memmove(buf, ta_str + ta_off, (size_t)maxlen); --- 130,136 ---- if (maxlen >= ta_len - ta_off) { mch_memmove(buf, ta_str + ta_off, (size_t)ta_len); ! VIM_CLEAR(ta_str); return ta_len; } mch_memmove(buf, ta_str + ta_off, (size_t)maxlen); *************** *** 1840,1849 **** unconverted = restlen; mch_memmove(inbuf + inbufcount, rest, unconverted); if (unconverted == restlen) ! { ! vim_free(rest); ! rest = NULL; ! } else { restlen -= unconverted; --- 1839,1845 ---- unconverted = restlen; mch_memmove(inbuf + inbufcount, rest, unconverted); if (unconverted == restlen) ! VIM_CLEAR(rest); else { restlen -= unconverted; *** ../vim-8.0.1495/src/undo.c 2018-01-31 14:25:49.914406580 +0100 --- src/undo.c 2018-02-10 18:34:41.477419820 +0100 *************** *** 849,856 **** if (undo_file_name != NULL && (!reading || mch_stat((char *)undo_file_name, &st) >= 0)) break; ! vim_free(undo_file_name); ! undo_file_name = NULL; } vim_free(munged_name); --- 849,855 ---- if (undo_file_name != NULL && (!reading || mch_stat((char *)undo_file_name, &st) >= 0)) break; ! VIM_CLEAR(undo_file_name); } vim_free(munged_name); *************** *** 3454,3461 **** { if (curbuf->b_u_line_ptr != NULL) { ! vim_free(curbuf->b_u_line_ptr); ! curbuf->b_u_line_ptr = NULL; curbuf->b_u_line_lnum = 0; } } --- 3453,3459 ---- { if (curbuf->b_u_line_ptr != NULL) { ! VIM_CLEAR(curbuf->b_u_line_ptr); curbuf->b_u_line_lnum = 0; } } *** ../vim-8.0.1495/src/userfunc.c 2017-12-22 21:49:53.710738779 +0100 --- src/userfunc.c 2018-02-10 18:34:41.477419820 +0100 *************** *** 2122,2131 **** /* between ":append" and "." and between ":python <uf_args)); ga_clear_strings(&(fp->uf_lines)); ! vim_free(name); ! name = NULL; } } } --- 2292,2298 ---- /* redefine existing function */ ga_clear_strings(&(fp->uf_args)); ga_clear_strings(&(fp->uf_lines)); ! VIM_CLEAR(name); } } } *** ../vim-8.0.1495/src/window.c 2018-01-31 19:06:45.446257165 +0100 --- src/window.c 2018-02-10 18:34:41.477419820 +0100 *************** *** 4415,4422 **** /* Window doesn't have a local directory and we are not in the global * directory: Change to the global directory. */ ignored = mch_chdir((char *)globaldir); ! vim_free(globaldir); ! globaldir = NULL; shorten_fnames(TRUE); } --- 4415,4421 ---- /* Window doesn't have a local directory and we are not in the global * directory: Change to the global directory. */ ignored = mch_chdir((char *)globaldir); ! VIM_CLEAR(globaldir); shorten_fnames(TRUE); } *************** *** 4847,4856 **** { /* TODO: why would wp be NULL here? */ if (wp != NULL) ! { ! vim_free(wp->w_lines); ! wp->w_lines = NULL; ! } } /* --- 4846,4852 ---- { /* TODO: why would wp be NULL here? */ if (wp != NULL) ! VIM_CLEAR(wp->w_lines); } /* *** ../vim-8.0.1495/src/version.c 2018-02-10 18:28:48.191960269 +0100 --- src/version.c 2018-02-10 18:37:22.012271437 +0100 *************** *** 773,774 **** --- 773,776 ---- { /* Add new patch number below this line */ + /**/ + 1496, /**/ -- A computer programmer is a device for turning requirements into undocumented features. It runs on cola, pizza and Dilbert cartoons. Bram Moolenaar /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\ /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\ \\\ an exciting new programming language -- http://www.Zimbu.org /// \\\ help me help AIDS victims -- http://ICCF-Holland.org ///