Mercurial > vim
changeset 2770:25672ad7f377 v7.3.161
updated for version 7.3.161
Problem: Items on the stack may be too big.
Solution: Make items static or allocate them.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Mon, 11 Apr 2011 21:35:11 +0200 |
parents | ccce1db172b3 |
children | 987cd9455925 |
files | src/eval.c src/ex_cmds.c src/ex_cmds2.c src/ex_docmd.c src/fileio.c src/hardcopy.c src/main.c src/netbeans.c src/quickfix.c src/spell.c src/tag.c src/version.c src/vim.h src/xxd/xxd.c |
diffstat | 14 files changed, 282 insertions(+), 130 deletions(-) [+] |
line wrap: on
line diff
--- a/src/eval.c +++ b/src/eval.c @@ -11100,18 +11100,22 @@ f_getcwd(argvars, rettv) typval_T *argvars UNUSED; typval_T *rettv; { - char_u cwd[MAXPATHL]; - - rettv->v_type = VAR_STRING; - if (mch_dirname(cwd, MAXPATHL) == FAIL) - rettv->vval.v_string = NULL; - else - { - rettv->vval.v_string = vim_strsave(cwd); + char_u *cwd; + + rettv->v_type = VAR_STRING; + rettv->vval.v_string = NULL; + cwd = alloc(MAXPATHL); + if (cwd != NULL) + { + if (mch_dirname(cwd, MAXPATHL) != FAIL) + { + rettv->vval.v_string = vim_strsave(cwd); #ifdef BACKSLASH_IN_FILENAME - if (rettv->vval.v_string != NULL) - slash_adjust(rettv->vval.v_string); -#endif + if (rettv->vval.v_string != NULL) + slash_adjust(rettv->vval.v_string); +#endif + } + vim_free(cwd); } } @@ -14938,6 +14942,9 @@ f_resolve(argvars, rettv) typval_T *rettv; { char_u *p; +#ifdef HAVE_READLINK + char_u *buf = NULL; +#endif p = get_tv_string(&argvars[0]); #ifdef FEAT_SHORTCUT @@ -14953,7 +14960,6 @@ f_resolve(argvars, rettv) #else # ifdef HAVE_READLINK { - char_u buf[MAXPATHL + 1]; char_u *cpy; int len; char_u *remain = NULL; @@ -14981,6 +14987,10 @@ f_resolve(argvars, rettv) q[-1] = NUL; } + buf = alloc(MAXPATHL + 1); + if (buf == NULL) + goto fail; + for (;;) { for (;;) @@ -15124,6 +15134,7 @@ f_resolve(argvars, rettv) #ifdef HAVE_READLINK fail: + vim_free(buf); #endif rettv->v_type = VAR_STRING; } @@ -17604,18 +17615,22 @@ f_tagfiles(argvars, rettv) typval_T *argvars UNUSED; typval_T *rettv; { - char_u fname[MAXPATHL + 1]; + char_u *fname; tagname_T tn; int first; if (rettv_list_alloc(rettv) == FAIL) return; + fname = alloc(MAXPATHL); + if (fname == NULL) + return; for (first = TRUE; ; first = FALSE) if (get_tagfname(&tn, first, fname) == FAIL || list_append_string(rettv->vval.v_list, fname, -1) == FAIL) break; tagname_free(&tn); + vim_free(fname); } /*
--- a/src/ex_cmds.c +++ b/src/ex_cmds.c @@ -2777,7 +2777,7 @@ check_overwrite(eap, buf, fname, ffname, #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) if (p_confirm || cmdmod.confirm) { - char_u buff[IOSIZE]; + char_u buff[DIALOG_MSG_SIZE]; dialog_msg(buff, _("Overwrite existing file \"%s\"?"), fname); if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 2) != VIM_YES) @@ -2795,7 +2795,7 @@ check_overwrite(eap, buf, fname, ffname, /* For ":w! filename" check that no swap file exists for "filename". */ if (other && !emsg_silent) { - char_u dir[MAXPATHL]; + char_u *dir; char_u *p; int r; char_u *swapname; @@ -2806,20 +2806,29 @@ check_overwrite(eap, buf, fname, ffname, * Use 'shortname' of the current buffer, since there is no buffer * for the written file. */ if (*p_dir == NUL) + { + dir = alloc(5); + if (dir == NULL) + return FAIL; STRCPY(dir, "."); + } else { + dir = alloc(MAXPATHL); + if (dir == NULL) + return FAIL; p = p_dir; copy_option_part(&p, dir, MAXPATHL, ","); } swapname = makeswapname(fname, ffname, curbuf, dir); + vim_free(dir); r = vim_fexists(swapname); if (r) { #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) if (p_confirm || cmdmod.confirm) { - char_u buff[IOSIZE]; + char_u buff[DIALOG_MSG_SIZE]; dialog_msg(buff, _("Swap file \"%s\" exists, overwrite anyway?"), @@ -2969,7 +2978,7 @@ check_readonly(forceit, buf) #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) if ((p_confirm || cmdmod.confirm) && buf->b_fname != NULL) { - char_u buff[IOSIZE]; + char_u buff[DIALOG_MSG_SIZE]; if (buf->b_p_ro) dialog_msg(buff, _("'readonly' option is set for \"%s\".\nDo you wish to write anyway?"),
--- a/src/ex_cmds2.c +++ b/src/ex_cmds2.c @@ -1492,7 +1492,7 @@ dialog_changed(buf, checkall) buf_T *buf; int checkall; /* may abandon all changed buffers */ { - char_u buff[IOSIZE]; + char_u buff[DIALOG_MSG_SIZE]; int ret; buf_T *buf2;
--- a/src/ex_docmd.c +++ b/src/ex_docmd.c @@ -5093,14 +5093,14 @@ check_more(message, forceit) #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) if ((p_confirm || cmdmod.confirm) && curbuf->b_fname != NULL) { - char_u buff[IOSIZE]; + char_u buff[DIALOG_MSG_SIZE]; if (n == 1) vim_strncpy(buff, (char_u *)_("1 more file to edit. Quit anyway?"), - IOSIZE - 1); + DIALOG_MSG_SIZE - 1); else - vim_snprintf((char *)buff, IOSIZE, + vim_snprintf((char *)buff, DIALOG_MSG_SIZE, _("%d more files to edit. Quit anyway?"), n); if (vim_dialog_yesno(VIM_QUESTION, NULL, buff, 1) == VIM_YES) return OK; @@ -8926,35 +8926,42 @@ ex_mkrc(eap) failed = TRUE; if (eap->cmdidx == CMD_mksession) { - char_u dirnow[MAXPATHL]; /* current directory */ - - /* - * Change to session file's dir. - */ - if (mch_dirname(dirnow, MAXPATHL) == FAIL + char_u *dirnow; /* current directory */ + + dirnow = alloc(MAXPATHL); + if (dirnow == NULL) + failed = TRUE; + else + { + /* + * Change to session file's dir. + */ + if (mch_dirname(dirnow, MAXPATHL) == FAIL || mch_chdir((char *)dirnow) != 0) - *dirnow = NUL; - if (*dirnow != NUL && (ssop_flags & SSOP_SESDIR)) - { - if (vim_chdirfile(fname) == OK) + *dirnow = NUL; + if (*dirnow != NUL && (ssop_flags & SSOP_SESDIR)) + { + if (vim_chdirfile(fname) == OK) + shorten_fnames(TRUE); + } + else if (*dirnow != NUL + && (ssop_flags & SSOP_CURDIR) && globaldir != NULL) + { + if (mch_chdir((char *)globaldir) == 0) + shorten_fnames(TRUE); + } + + failed |= (makeopens(fd, dirnow) == FAIL); + + /* restore original dir */ + if (*dirnow != NUL && ((ssop_flags & SSOP_SESDIR) + || ((ssop_flags & SSOP_CURDIR) && globaldir != NULL))) + { + if (mch_chdir((char *)dirnow) != 0) + EMSG(_(e_prev_dir)); shorten_fnames(TRUE); - } - else if (*dirnow != NUL - && (ssop_flags & SSOP_CURDIR) && globaldir != NULL) - { - if (mch_chdir((char *)globaldir) == 0) - shorten_fnames(TRUE); - } - - failed |= (makeopens(fd, dirnow) == FAIL); - - /* restore original dir */ - if (*dirnow != NUL && ((ssop_flags & SSOP_SESDIR) - || ((ssop_flags & SSOP_CURDIR) && globaldir != NULL))) - { - if (mch_chdir((char *)dirnow) != 0) - EMSG(_(e_prev_dir)); - shorten_fnames(TRUE); + } + vim_free(dirnow); } } else @@ -8985,10 +8992,15 @@ ex_mkrc(eap) else if (eap->cmdidx == CMD_mksession) { /* successful session write - set this_session var */ - char_u tbuf[MAXPATHL]; - - if (vim_FullName(fname, tbuf, MAXPATHL, FALSE) == OK) - set_vim_var_string(VV_THIS_SESSION, tbuf, -1); + char_u *tbuf; + + tbuf = alloc(MAXPATHL); + if (tbuf != NULL) + { + if (vim_FullName(fname, tbuf, MAXPATHL, FALSE) == OK) + set_vim_var_string(VV_THIS_SESSION, tbuf, -1); + vim_free(tbuf); + } } #endif #ifdef MKSESSION_NL @@ -10677,7 +10689,7 @@ ses_arglist(fd, cmd, gap, fullname, flag unsigned *flagp; { int i; - char_u buf[MAXPATHL]; + char_u *buf = NULL; char_u *s; if (gap->ga_len == 0) @@ -10692,11 +10704,19 @@ ses_arglist(fd, cmd, gap, fullname, flag { if (fullname) { - (void)vim_FullName(s, buf, MAXPATHL, FALSE); - s = buf; + buf = alloc(MAXPATHL); + if (buf != NULL) + { + (void)vim_FullName(s, buf, MAXPATHL, FALSE); + s = buf; + } } if (fputs(" ", fd) < 0 || ses_put_fname(fd, s, flagp) == FAIL) + { + vim_free(buf); return FAIL; + } + vim_free(buf); } } return put_eol(fd); @@ -10925,7 +10945,7 @@ ex_viminfo(eap) #if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG) || defined(PROTO) /* - * Make a dialog message in "buff[IOSIZE]". + * Make a dialog message in "buff[DIALOG_MSG_SIZE]". * "format" must contain "%s". */ void @@ -10936,7 +10956,7 @@ dialog_msg(buff, format, fname) { if (fname == NULL) fname = (char_u *)_("Untitled"); - vim_snprintf((char *)buff, IOSIZE, format, fname); + vim_snprintf((char *)buff, DIALOG_MSG_SIZE, format, fname); } #endif
--- a/src/fileio.c +++ b/src/fileio.c @@ -6023,15 +6023,19 @@ make_bom(buf, name) shorten_fname1(full_path) char_u *full_path; { - char_u dirname[MAXPATHL]; + char_u *dirname; char_u *p = full_path; + dirname = alloc(MAXPATHL); + if (dirname == NULL) + return full_path; if (mch_dirname(dirname, MAXPATHL) == OK) { p = shorten_fname(full_path, dirname); if (p == NULL || *p == NUL) p = full_path; } + vim_free(dirname); return p; } #endif
--- a/src/hardcopy.c +++ b/src/hardcopy.c @@ -1759,7 +1759,12 @@ prt_find_resource(name, resource) char *name; struct prt_ps_resource_S *resource; { - char_u buffer[MAXPATHL + 1]; + char_u *buffer; + int retval; + + buffer = alloc(MAXPATHL + 1); + if (buffer == NULL) + return FALSE; vim_strncpy(resource->name, (char_u *)name, 63); /* Look for named resource file in runtimepath */ @@ -1768,9 +1773,11 @@ prt_find_resource(name, resource) vim_strcat(buffer, (char_u *)name, MAXPATHL); vim_strcat(buffer, (char_u *)".ps", MAXPATHL); resource->filename[0] = NUL; - return (do_in_runtimepath(buffer, FALSE, prt_resource_name, + retval = (do_in_runtimepath(buffer, FALSE, prt_resource_name, resource->filename) && resource->filename[0] != NUL); + vim_free(buffer); + return retval; } /* PS CR and LF characters have platform independent values */ @@ -2848,15 +2855,33 @@ mch_print_begin(psettings) double right; double top; double bottom; - struct prt_ps_resource_S res_prolog; - struct prt_ps_resource_S res_encoding; + struct prt_ps_resource_S *res_prolog; + struct prt_ps_resource_S *res_encoding; char buffer[256]; char_u *p_encoding; char_u *p; #ifdef FEAT_MBYTE - struct prt_ps_resource_S res_cidfont; - struct prt_ps_resource_S res_cmap; + struct prt_ps_resource_S *res_cidfont; + struct prt_ps_resource_S *res_cmap; #endif + int retval = FALSE; + + res_prolog = (struct prt_ps_resource_S *) + alloc(sizeof(struct prt_ps_resource_S)); + res_encoding = (struct prt_ps_resource_S *) + alloc(sizeof(struct prt_ps_resource_S)); +#ifdef FEAT_MBYTE + res_cidfont = (struct prt_ps_resource_S *) + alloc(sizeof(struct prt_ps_resource_S)); + res_cmap = (struct prt_ps_resource_S *) + alloc(sizeof(struct prt_ps_resource_S)); +#endif + if (res_prolog == NULL || res_encoding == NULL +#ifdef FEAT_MBYTE + || res_cidfont == NULL || res_cmap == NULL +#endif + ) + goto theend; /* * PS DSC Header comments - no PS code! @@ -2932,27 +2957,27 @@ mch_print_begin(psettings) #endif /* Search for external resources VIM supplies */ - if (!prt_find_resource("prolog", &res_prolog)) + if (!prt_find_resource("prolog", res_prolog)) { EMSG(_("E456: Can't find PostScript resource file \"prolog.ps\"")); return FALSE; } - if (!prt_open_resource(&res_prolog)) + if (!prt_open_resource(res_prolog)) return FALSE; - if (!prt_check_resource(&res_prolog, PRT_PROLOG_VERSION)) + if (!prt_check_resource(res_prolog, PRT_PROLOG_VERSION)) return FALSE; #ifdef FEAT_MBYTE if (prt_out_mbyte) { /* Look for required version of multi-byte printing procset */ - if (!prt_find_resource("cidfont", &res_cidfont)) + if (!prt_find_resource("cidfont", res_cidfont)) { EMSG(_("E456: Can't find PostScript resource file \"cidfont.ps\"")); return FALSE; } - if (!prt_open_resource(&res_cidfont)) + if (!prt_open_resource(res_cidfont)) return FALSE; - if (!prt_check_resource(&res_cidfont, PRT_CID_PROLOG_VERSION)) + if (!prt_check_resource(res_cidfont, PRT_CID_PROLOG_VERSION)) return FALSE; } #endif @@ -2968,7 +2993,7 @@ mch_print_begin(psettings) #endif p_encoding = enc_skip(p_penc); if (*p_encoding == NUL - || !prt_find_resource((char *)p_encoding, &res_encoding)) + || !prt_find_resource((char *)p_encoding, res_encoding)) { /* 'printencoding' not set or not supported - find alternate */ #ifdef FEAT_MBYTE @@ -2977,13 +3002,13 @@ mch_print_begin(psettings) p_encoding = enc_skip(p_enc); props = enc_canon_props(p_encoding); if (!(props & ENC_8BIT) - || !prt_find_resource((char *)p_encoding, &res_encoding)) + || !prt_find_resource((char *)p_encoding, res_encoding)) /* 8-bit 'encoding' is not supported */ #endif { /* Use latin1 as default printing encoding */ p_encoding = (char_u *)"latin1"; - if (!prt_find_resource((char *)p_encoding, &res_encoding)) + if (!prt_find_resource((char *)p_encoding, res_encoding)) { EMSG2(_("E456: Can't find PostScript resource file \"%s.ps\""), p_encoding); @@ -2991,7 +3016,7 @@ mch_print_begin(psettings) } } } - if (!prt_open_resource(&res_encoding)) + if (!prt_open_resource(res_encoding)) return FALSE; /* For the moment there are no checks on encoding resource files to * perform */ @@ -3005,13 +3030,13 @@ mch_print_begin(psettings) if (prt_use_courier) { /* Include ASCII range encoding vector */ - if (!prt_find_resource(prt_ascii_encoding, &res_encoding)) + if (!prt_find_resource(prt_ascii_encoding, res_encoding)) { EMSG2(_("E456: Can't find PostScript resource file \"%s.ps\""), prt_ascii_encoding); return FALSE; } - if (!prt_open_resource(&res_encoding)) + if (!prt_open_resource(res_encoding)) return FALSE; /* For the moment there are no checks on encoding resource files to * perform */ @@ -3034,44 +3059,44 @@ mch_print_begin(psettings) if (prt_out_mbyte && prt_custom_cmap) { /* Find user supplied CMap */ - if (!prt_find_resource(prt_cmap, &res_cmap)) + if (!prt_find_resource(prt_cmap, res_cmap)) { EMSG2(_("E456: Can't find PostScript resource file \"%s.ps\""), prt_cmap); return FALSE; } - if (!prt_open_resource(&res_cmap)) + if (!prt_open_resource(res_cmap)) return FALSE; } #endif /* List resources supplied */ - STRCPY(buffer, res_prolog.title); + STRCPY(buffer, res_prolog->title); STRCAT(buffer, " "); - STRCAT(buffer, res_prolog.version); + STRCAT(buffer, res_prolog->version); prt_dsc_resources("DocumentSuppliedResources", "procset", buffer); #ifdef FEAT_MBYTE if (prt_out_mbyte) { - STRCPY(buffer, res_cidfont.title); + STRCPY(buffer, res_cidfont->title); STRCAT(buffer, " "); - STRCAT(buffer, res_cidfont.version); + STRCAT(buffer, res_cidfont->version); prt_dsc_resources(NULL, "procset", buffer); if (prt_custom_cmap) { - STRCPY(buffer, res_cmap.title); + STRCPY(buffer, res_cmap->title); STRCAT(buffer, " "); - STRCAT(buffer, res_cmap.version); + STRCAT(buffer, res_cmap->version); prt_dsc_resources(NULL, "cmap", buffer); } } if (!prt_out_mbyte || prt_use_courier) #endif { - STRCPY(buffer, res_encoding.title); + STRCPY(buffer, res_encoding->title); STRCAT(buffer, " "); - STRCAT(buffer, res_encoding.version); + STRCAT(buffer, res_encoding->version); prt_dsc_resources(NULL, "encoding", buffer); } prt_dsc_requirements(prt_duplex, prt_tumble, prt_collate, @@ -3114,15 +3139,15 @@ mch_print_begin(psettings) prt_dsc_noarg("BeginProlog"); /* Add required procsets - NOTE: order is important! */ - if (!prt_add_resource(&res_prolog)) + if (!prt_add_resource(res_prolog)) return FALSE; #ifdef FEAT_MBYTE if (prt_out_mbyte) { /* Add CID font procset, and any user supplied CMap */ - if (!prt_add_resource(&res_cidfont)) + if (!prt_add_resource(res_cidfont)) return FALSE; - if (prt_custom_cmap && !prt_add_resource(&res_cmap)) + if (prt_custom_cmap && !prt_add_resource(res_cmap)) return FALSE; } #endif @@ -3132,7 +3157,7 @@ mch_print_begin(psettings) #endif /* There will be only one Roman font encoding to be included in the PS * file. */ - if (!prt_add_resource(&res_encoding)) + if (!prt_add_resource(res_encoding)) return FALSE; prt_dsc_noarg("EndProlog"); @@ -3248,7 +3273,17 @@ mch_print_begin(psettings) prt_dsc_noarg("EndSetup"); /* Fail if any problems writing out to the PS file */ - return !prt_file_error; + retval = !prt_file_error; + +theend: + vim_free(res_prolog); + vim_free(res_encoding); +#ifdef FEAT_MBYTE + vim_free(res_cidfont); + vim_free(res_cmap); +#endif + + return retval; } void
--- a/src/main.c +++ b/src/main.c @@ -3814,7 +3814,7 @@ build_drop_cmd(filec, filev, tabs, sendR int i; char_u *inicmd = NULL; char_u *p; - char_u cwd[MAXPATHL]; + char_u *cwd; if (filec > 0 && filev[0][0] == '+') { @@ -3827,15 +3827,23 @@ build_drop_cmd(filec, filev, tabs, sendR mainerr_arg_missing((char_u *)filev[-1]); /* Temporarily cd to the current directory to handle relative file names. */ - if (mch_dirname(cwd, MAXPATHL) != OK) + cwd = alloc(MAXPATHL); + if (cwd == NULL) return NULL; - if ((p = vim_strsave_escaped_ext(cwd, + if (mch_dirname(cwd, MAXPATHL) != OK) + { + vim_free(cwd); + return NULL; + } + p = vim_strsave_escaped_ext(cwd, #ifdef BACKSLASH_IN_FILENAME "", /* rem_backslash() will tell what chars to escape */ #else PATH_ESC_CHARS, #endif - '\\', TRUE)) == NULL) + '\\', TRUE); + vim_free(cwd); + if (p == NULL) return NULL; ga_init2(&ga, 1, 100); ga_concat(&ga, (char_u *)"<C-\\><C-N>:cd ");
--- a/src/netbeans.c +++ b/src/netbeans.c @@ -2891,7 +2891,7 @@ netbeans_beval_cb( char_u *text; linenr_T lnum; int col; - char buf[MAXPATHL * 2 + 25]; + char *buf; char_u *p; /* Don't do anything when 'ballooneval' is off, messages scrolled the @@ -2905,15 +2905,20 @@ netbeans_beval_cb( * length. */ if (text != NULL && text[0] != NUL && STRLEN(text) < MAXPATHL) { - p = nb_quote(text); - if (p != NULL) + buf = (char *)alloc(MAXPATHL * 2 + 25); + if (buf != NULL) { - vim_snprintf(buf, sizeof(buf), - "0:balloonText=%d \"%s\"\n", r_cmdno, p); - vim_free(p); + p = nb_quote(text); + if (p != NULL) + { + vim_snprintf(buf, MAXPATHL * 2 + 25, + "0:balloonText=%d \"%s\"\n", r_cmdno, p); + vim_free(p); + } + nbdebug(("EVT: %s", buf)); + nb_send(buf, "netbeans_beval_cb"); + vim_free(buf); } - nbdebug(("EVT: %s", buf)); - nb_send(buf, "netbeans_beval_cb"); } vim_free(text); }
--- a/src/quickfix.c +++ b/src/quickfix.c @@ -3049,8 +3049,8 @@ ex_vimgrep(eap) int flags = 0; colnr_T col; long tomatch; - char_u dirname_start[MAXPATHL]; - char_u dirname_now[MAXPATHL]; + char_u *dirname_start = NULL; + char_u *dirname_now = NULL; char_u *target_dir = NULL; #ifdef FEAT_AUTOCMD char_u *au_name = NULL; @@ -3128,6 +3128,11 @@ ex_vimgrep(eap) goto theend; } + dirname_start = alloc(MAXPATHL); + dirname_now = alloc(MAXPATHL); + if (dirname_start == NULL || dirname_now == NULL) + goto theend; + /* Remember the current directory, because a BufRead autocommand that does * ":lcd %:p:h" changes the meaning of short path names. */ mch_dirname(dirname_start, MAXPATHL); @@ -3364,6 +3369,8 @@ ex_vimgrep(eap) } theend: + vim_free(dirname_now); + vim_free(dirname_start); vim_free(target_dir); vim_free(regmatch.regprog); }
--- a/src/spell.c +++ b/src/spell.c @@ -8590,7 +8590,7 @@ spell_make_sugfile(spin, wfname) spellinfo_T *spin; char_u *wfname; { - char_u fname[MAXPATHL]; + char_u *fname = NULL; int len; slang_T *slang; int free_slang = FALSE; @@ -8654,6 +8654,9 @@ spell_make_sugfile(spin, wfname) * Write the .sug file. * Make the file name by changing ".spl" to ".sug". */ + fname = alloc(MAXPATHL); + if (fname == NULL) + goto theend; vim_strncpy(fname, wfname, MAXPATHL - 1); len = (int)STRLEN(fname); fname[len - 2] = 'u'; @@ -8661,6 +8664,7 @@ spell_make_sugfile(spin, wfname) sug_write(spin, fname); theend: + vim_free(fname); if (free_slang) slang_free(slang); free_blocks(spin->si_blocks); @@ -9106,8 +9110,8 @@ mkspell(fcount, fnames, ascii, overwrite int overwrite; /* overwrite existing output file */ int added_word; /* invoked through "zg" */ { - char_u fname[MAXPATHL]; - char_u wfname[MAXPATHL]; + char_u *fname = NULL; + char_u *wfname; char_u **innames; int incount; afffile_T *(afile[8]); @@ -9135,6 +9139,10 @@ mkspell(fcount, fnames, ascii, overwrite innames = &fnames[1]; incount = fcount - 1; + wfname = alloc(MAXPATHL); + if (wfname == NULL) + return; + if (fcount >= 1) { len = (int)STRLEN(fnames[0]); @@ -9144,24 +9152,24 @@ mkspell(fcount, fnames, ascii, overwrite * "path/en.latin1.add.spl". */ innames = &fnames[0]; incount = 1; - vim_snprintf((char *)wfname, sizeof(wfname), "%s.spl", fnames[0]); + vim_snprintf((char *)wfname, MAXPATHL, "%s.spl", fnames[0]); } else if (fcount == 1) { /* For ":mkspell path/vim" output file is "path/vim.latin1.spl". */ innames = &fnames[0]; incount = 1; - vim_snprintf((char *)wfname, sizeof(wfname), SPL_FNAME_TMPL, + vim_snprintf((char *)wfname, MAXPATHL, SPL_FNAME_TMPL, fnames[0], spin.si_ascii ? (char_u *)"ascii" : spell_enc()); } else if (len > 4 && STRCMP(fnames[0] + len - 4, ".spl") == 0) { /* Name ends in ".spl", use as the file name. */ - vim_strncpy(wfname, fnames[0], sizeof(wfname) - 1); + vim_strncpy(wfname, fnames[0], MAXPATHL - 1); } else /* Name should be language, make the file name from it. */ - vim_snprintf((char *)wfname, sizeof(wfname), SPL_FNAME_TMPL, + vim_snprintf((char *)wfname, MAXPATHL, SPL_FNAME_TMPL, fnames[0], spin.si_ascii ? (char_u *)"ascii" : spell_enc()); /* Check for .ascii.spl. */ @@ -9186,13 +9194,17 @@ mkspell(fcount, fnames, ascii, overwrite if (!overwrite && mch_stat((char *)wfname, &st) >= 0) { EMSG(_(e_exists)); - return; + goto theend; } if (mch_isdir(wfname)) { EMSG2(_(e_isadir2), wfname); - return; - } + goto theend; + } + + fname = alloc(MAXPATHL); + if (fname == NULL) + goto theend; /* * Init the aff and dic pointers. @@ -9209,7 +9221,7 @@ mkspell(fcount, fnames, ascii, overwrite || innames[i][len - 3] != '_') { EMSG2(_("E755: Invalid region in %s"), innames[i]); - return; + goto theend; } spin.si_region_name[i * 2] = TOLOWER_ASC(innames[i][len - 2]); spin.si_region_name[i * 2 + 1] = @@ -9226,7 +9238,7 @@ mkspell(fcount, fnames, ascii, overwrite || spin.si_prefroot == NULL) { free_blocks(spin.si_blocks); - return; + goto theend; } /* When not producing a .add.spl file clear the character table when @@ -9247,7 +9259,7 @@ mkspell(fcount, fnames, ascii, overwrite spin.si_conv.vc_type = CONV_NONE; spin.si_region = 1 << i; - vim_snprintf((char *)fname, sizeof(fname), "%s.aff", innames[i]); + vim_snprintf((char *)fname, MAXPATHL, "%s.aff", innames[i]); if (mch_stat((char *)fname, &st) >= 0) { /* Read the .aff file. Will init "spin->si_conv" based on the @@ -9258,7 +9270,7 @@ mkspell(fcount, fnames, ascii, overwrite else { /* Read the .dic file and store the words in the trees. */ - vim_snprintf((char *)fname, sizeof(fname), "%s.dic", + vim_snprintf((char *)fname, MAXPATHL, "%s.dic", innames[i]); if (spell_read_dic(&spin, fname, afile[i]) == FAIL) error = TRUE; @@ -9340,6 +9352,10 @@ mkspell(fcount, fnames, ascii, overwrite spell_make_sugfile(&spin, wfname); } + +theend: + vim_free(fname); + vim_free(wfname); } /* @@ -9392,7 +9408,7 @@ spell_add_word(word, len, bad, idx, undo buf_T *buf = NULL; int new_spf = FALSE; char_u *fname; - char_u fnamebuf[MAXPATHL]; + char_u *fnamebuf = NULL; char_u line[MAXWLEN * 2]; long fpos, fpos_next = 0; int i; @@ -9422,6 +9438,9 @@ spell_add_word(word, len, bad, idx, undo EMSG2(_(e_notset), "spellfile"); return; } + fnamebuf = alloc(MAXPATHL); + if (fnamebuf == NULL) + return; for (spf = curwin->w_s->b_p_spf, i = 1; *spf != NUL; ++i) { @@ -9431,6 +9450,7 @@ spell_add_word(word, len, bad, idx, undo if (*spf == NUL) { EMSGN(_("E765: 'spellfile' does not have %ld entries"), idx); + vim_free(fnamebuf); return; } } @@ -9442,6 +9462,7 @@ spell_add_word(word, len, bad, idx, undo if (buf != NULL && bufIsChanged(buf)) { EMSG(_(e_bufloaded)); + vim_free(fnamebuf); return; } @@ -9536,6 +9557,7 @@ spell_add_word(word, len, bad, idx, undo redraw_all_later(SOME_VALID); } + vim_free(fnamebuf); } /* @@ -9544,7 +9566,7 @@ spell_add_word(word, len, bad, idx, undo static void init_spellfile() { - char_u buf[MAXPATHL]; + char_u *buf; int l; char_u *fname; char_u *rtp; @@ -9554,6 +9576,10 @@ init_spellfile() if (*curwin->w_s->b_p_spl != NUL && curwin->w_s->b_langp.ga_len > 0) { + buf = alloc(MAXPATHL); + if (buf == NULL) + return; + /* Find the end of the language name. Exclude the region. If there * is a path separator remember the start of the tail. */ for (lend = curwin->w_s->b_p_spl; *lend != NUL @@ -9597,7 +9623,8 @@ init_spellfile() "/%.*s", (int)(lend - lstart), lstart); } l = (int)STRLEN(buf); - fname = LANGP_ENTRY(curwin->w_s->b_langp, 0)->lp_slang->sl_fname; + fname = LANGP_ENTRY(curwin->w_s->b_langp, 0) + ->lp_slang->sl_fname; vim_snprintf((char *)buf + l, MAXPATHL - l, ".%s.add", fname != NULL && strstr((char *)gettail(fname), ".ascii.") != NULL @@ -9607,6 +9634,8 @@ init_spellfile() } aspath = FALSE; } + + vim_free(buf); } }
--- a/src/tag.c +++ b/src/tag.c @@ -775,17 +775,25 @@ do_tag(tag, type, count, forceit, verbos { list_T *list; char_u tag_name[128 + 1]; - char_u fname[MAXPATHL + 1]; - char_u cmd[CMDBUFFSIZE + 1]; + char_u *fname; + char_u *cmd; /* * Add the matching tags to the location list for the current * window. */ + fname = alloc(MAXPATHL + 1); + cmd = alloc(CMDBUFFSIZE + 1); list = list_alloc(); - if (list == NULL) + if (list == NULL || fname == NULL || cmd == NULL) + { + vim_free(cmd); + vim_free(fname); + if (list != NULL) + list_free(list, TRUE); goto end_do_tag; + } for (i = 0; i < num_matches; ++i) { @@ -911,6 +919,8 @@ do_tag(tag, type, count, forceit, verbos set_errorlist(curwin, list, ' ', IObuff); list_free(list, TRUE); + vim_free(fname); + vim_free(cmd); cur_match = 0; /* Jump to the first tag */ } @@ -3777,8 +3787,9 @@ add_tag_field(dict, field_name, start, e char_u *start; /* start of the value */ char_u *end; /* after the value; can be NULL */ { - char_u buf[MAXPATHL]; + char_u *buf; int len = 0; + int retval; /* check that the field name doesn't exist yet */ if (dict_find(dict, (char_u *)field_name, -1) != NULL) @@ -3791,6 +3802,9 @@ add_tag_field(dict, field_name, start, e } return FAIL; } + buf = alloc(MAXPATHL); + if (buf == NULL) + return FAIL; if (start != NULL) { if (end == NULL) @@ -3800,12 +3814,14 @@ add_tag_field(dict, field_name, start, e --end; } len = (int)(end - start); - if (len > (int)sizeof(buf) - 1) - len = sizeof(buf) - 1; + if (len > MAXPATHL - 1) + len = MAXPATHL - 1; vim_strncpy(buf, start, len); } buf[len] = NUL; - return dict_add_nr_str(dict, field_name, 0L, buf); + retval = dict_add_nr_str(dict, field_name, 0L, buf); + vim_free(buf); + return retval; } /*
--- a/src/version.c +++ b/src/version.c @@ -715,6 +715,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 161, +/**/ 160, /**/ 159,
--- a/src/vim.h +++ b/src/vim.h @@ -1435,6 +1435,8 @@ typedef UINT32_TYPEDEF UINT32_T; #define IOSIZE (1024+1) /* file i/o and sprintf buffer size */ +#define DIALOG_MSG_SIZE 1000 /* buffer size for dialog_msg() */ + #ifdef FEAT_MBYTE # define MSG_BUF_LEN 480 /* length of buffer for small messages */ # define MSG_BUF_CLEN (MSG_BUF_LEN / 6) /* cell length (worst case: utf-8
--- a/src/xxd/xxd.c +++ b/src/xxd/xxd.c @@ -476,7 +476,7 @@ main(argc, argv) int octspergrp = -1; /* number of octets grouped in output */ int grplen; /* total chars per octet group */ long length = -1, n = 0, seekoff = 0; - char l[LLEN+1]; + static char l[LLEN+1]; /* static because it may be too big for stack */ char *pp; #ifdef AMIGA