comparison src/vim9script.c @ 30701:328f91a31951 v9.0.0685

patch 9.0.0685: FORTIFY_SOURCE causes a crash in Vim9 script Commit: https://github.com/vim/vim/commit/07eaa1ede4a39b6a95203beebd94943b62a216c1 Author: Yee Cheng Chin <ychin.git@gmail.com> Date: Fri Oct 7 16:00:04 2022 +0100 patch 9.0.0685: FORTIFY_SOURCE causes a crash in Vim9 script Problem: FORTIFY_SOURCE causes a crash in Vim9 script. Solution: Use a pointer to the first char. (Yee Cheng Chin, closes https://github.com/vim/vim/issues/11302)
author Bram Moolenaar <Bram@vim.org>
date Fri, 07 Oct 2022 17:15:03 +0200
parents 6b7020f3d856
children 12e6c7bae2a9
comparison
equal deleted inserted replaced
30700:1e8f19b459dd 30701:328f91a31951
138 si->sn_save_cpo = vim_strsave(p_cpo); 138 si->sn_save_cpo = vim_strsave(p_cpo);
139 set_option_value_give_err((char_u *)"cpo", 139 set_option_value_give_err((char_u *)"cpo",
140 0L, (char_u *)CPO_VIM, OPT_NO_REDRAW); 140 0L, (char_u *)CPO_VIM, OPT_NO_REDRAW);
141 } 141 }
142 #else 142 #else
143 // No check for this being the first command, it doesn't matter. 143 // No check for this being the first command, the information is not
144 // available.
144 current_sctx.sc_version = SCRIPT_VERSION_VIM9; 145 current_sctx.sc_version = SCRIPT_VERSION_VIM9;
145 #endif 146 #endif
146 } 147 }
147 148
148 #if defined(FEAT_EVAL) || defined(PROTO) 149 #if defined(FEAT_EVAL) || defined(PROTO)
967 sv->sv_flags = is_export ? SVFLAG_EXPORTED : 0; 968 sv->sv_flags = is_export ? SVFLAG_EXPORTED : 0;
968 if ((flags & ASSIGN_INIT) == 0) 969 if ((flags & ASSIGN_INIT) == 0)
969 sv->sv_flags |= SVFLAG_ASSIGNED; 970 sv->sv_flags |= SVFLAG_ASSIGNED;
970 newsav->sav_var_vals_idx = si->sn_var_vals.ga_len; 971 newsav->sav_var_vals_idx = si->sn_var_vals.ga_len;
971 ++si->sn_var_vals.ga_len; 972 ++si->sn_var_vals.ga_len;
972 STRCPY(&newsav->sav_key, name); 973 // a pointer to the first char avoids a FORTIFY_SOURCE problem
974 STRCPY(&newsav->sav_key[0], name);
973 sv->sv_name = newsav->sav_key; 975 sv->sv_name = newsav->sav_key;
974 newsav->sav_di = di; 976 newsav->sav_di = di;
975 newsav->sav_block_id = si->sn_current_block_id; 977 newsav->sav_block_id = si->sn_current_block_id;
976 978
977 if (HASHITEM_EMPTY(hi)) 979 if (HASHITEM_EMPTY(hi))