Skip to content

Commit 66250c9

Browse files
committed
patch 8.2.1491: Vim9: crash when compiling heredoc lines start with comment
Problem: Vim9: crash when compiling heredoc lines start with comment. Solution: Skip over NULL pointers. Do not remove comment and empty lines when fetching function lines. (closes #6743)
1 parent 93ad147 commit 66250c9

16 files changed

Lines changed: 81 additions & 45 deletions

src/autocmd.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2310,7 +2310,11 @@ auto_next_pat(
23102310
* Returns allocated string, or NULL for end of autocommands.
23112311
*/
23122312
char_u *
2313-
getnextac(int c UNUSED, void *cookie, int indent UNUSED, int do_concat UNUSED)
2313+
getnextac(
2314+
int c UNUSED,
2315+
void *cookie,
2316+
int indent UNUSED,
2317+
getline_opt_T options UNUSED)
23142318
{
23152319
AutoPatCmd *acp = (AutoPatCmd *)cookie;
23162320
char_u *retval;

src/evalfunc.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2198,13 +2198,12 @@ execute_redir_str(char_u *value, int value_len)
21982198
* Called by do_cmdline() to get the next line.
21992199
* Returns allocated string, or NULL for end of function.
22002200
*/
2201-
22022201
static char_u *
22032202
get_list_line(
22042203
int c UNUSED,
22052204
void *cookie,
22062205
int indent UNUSED,
2207-
int do_concat UNUSED)
2206+
getline_opt_T options UNUSED)
22082207
{
22092208
listitem_T **p = (listitem_T **)cookie;
22102209
listitem_T *item = *p;

src/ex_cmds.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1867,7 +1867,7 @@ struct exarg
18671867
int bad_char; // BAD_KEEP, BAD_DROP or replacement byte
18681868
int useridx; // user command index
18691869
char *errmsg; // returned error message
1870-
char_u *(*getline)(int, void *, int, int);
1870+
char_u *(*getline)(int, void *, int, getline_opt_T);
18711871
void *cookie; // argument for getline()
18721872
#ifdef FEAT_EVAL
18731873
cstack_T *cstack; // condition stack for ":if" etc.

src/ex_docmd.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ do_cmdline_cmd(char_u *cmd)
612612
int
613613
do_cmdline(
614614
char_u *cmdline,
615-
char_u *(*fgetline)(int, void *, int, int),
615+
char_u *(*fgetline)(int, void *, int, getline_opt_T),
616616
void *cookie, // argument for fgetline()
617617
int flags)
618618
{
@@ -638,7 +638,7 @@ do_cmdline(
638638
msglist_T *private_msg_list;
639639

640640
// "fgetline" and "cookie" passed to do_one_cmd()
641-
char_u *(*cmd_getline)(int, void *, int, int);
641+
char_u *(*cmd_getline)(int, void *, int, getline_opt_T);
642642
void *cmd_cookie;
643643
struct loop_cookie cmd_loop_cookie;
644644
void *real_cookie;
@@ -1482,9 +1482,9 @@ free_cmdlines(garray_T *gap)
14821482
*/
14831483
int
14841484
getline_equal(
1485-
char_u *(*fgetline)(int, void *, int, int),
1485+
char_u *(*fgetline)(int, void *, int, getline_opt_T),
14861486
void *cookie UNUSED, // argument for fgetline()
1487-
char_u *(*func)(int, void *, int, int))
1487+
char_u *(*func)(int, void *, int, getline_opt_T))
14881488
{
14891489
#ifdef FEAT_EVAL
14901490
char_u *(*gp)(int, void *, int, int);
@@ -1512,7 +1512,7 @@ getline_equal(
15121512
*/
15131513
void *
15141514
getline_cookie(
1515-
char_u *(*fgetline)(int, void *, int, int) UNUSED,
1515+
char_u *(*fgetline)(int, void *, int, getline_opt_T) UNUSED,
15161516
void *cookie) // argument for fgetline()
15171517
{
15181518
#ifdef FEAT_EVAL
@@ -1541,7 +1541,7 @@ getline_cookie(
15411541
*/
15421542
char_u *
15431543
getline_peek(
1544-
char_u *(*fgetline)(int, void *, int, int) UNUSED,
1544+
char_u *(*fgetline)(int, void *, int, getline_opt_T) UNUSED,
15451545
void *cookie) // argument for fgetline()
15461546
{
15471547
char_u *(*gp)(int, void *, int, int);

src/ex_getln.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2705,12 +2705,12 @@ getexline(
27052705
int c, // normally ':', NUL for ":append"
27062706
void *cookie UNUSED,
27072707
int indent, // indent for inside conditionals
2708-
int do_concat)
2708+
getline_opt_T options)
27092709
{
27102710
// When executing a register, remove ':' that's in front of each line.
27112711
if (exec_from_reg && vpeekc() == ':')
27122712
(void)vgetc();
2713-
return getcmdline(c, 1L, indent, do_concat);
2713+
return getcmdline(c, 1L, indent, options);
27142714
}
27152715

27162716
/*
@@ -2725,7 +2725,7 @@ getexmodeline(
27252725
// :s prompt
27262726
void *cookie UNUSED,
27272727
int indent, // indent for inside conditionals
2728-
int do_concat UNUSED)
2728+
getline_opt_T options UNUSED)
27292729
{
27302730
garray_T line_ga;
27312731
char_u *pend;

src/proto/autocmd.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ int has_completechanged(void);
2828
void block_autocmds(void);
2929
void unblock_autocmds(void);
3030
int is_autocmd_blocked(void);
31-
char_u *getnextac(int c, void *cookie, int indent, int do_concat);
31+
char_u *getnextac(int c, void *cookie, int indent, getline_opt_T options);
3232
int has_autocmd(event_T event, char_u *sfname, buf_T *buf);
3333
char_u *get_augroup_name(expand_T *xp, int idx);
3434
char_u *set_context_in_autocmd(expand_T *xp, char_u *arg, int doautocmd);

src/proto/ex_docmd.pro

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/* ex_docmd.c */
22
void do_exmode(int improved);
33
int do_cmdline_cmd(char_u *cmd);
4-
int do_cmdline(char_u *cmdline, char_u *(*fgetline)(int, void *, int, int), void *cookie, int flags);
5-
int getline_equal(char_u *(*fgetline)(int, void *, int, int), void *cookie, char_u *(*func)(int, void *, int, int));
6-
void *getline_cookie(char_u *(*fgetline)(int, void *, int, int), void *cookie);
7-
char_u *getline_peek(char_u *(*fgetline)(int, void *, int, int), void *cookie);
4+
int do_cmdline(char_u *cmdline, char_u *(*fgetline)(int, void *, int, getline_opt_T), void *cookie, int flags);
5+
int getline_equal(char_u *(*fgetline)(int, void *, int, getline_opt_T), void *cookie, char_u *(*func)(int, void *, int, getline_opt_T));
6+
void *getline_cookie(char_u *(*fgetline)(int, void *, int, getline_opt_T), void *cookie);
7+
char_u *getline_peek(char_u *(*fgetline)(int, void *, int, getline_opt_T), void *cookie);
88
char *ex_errmsg(char *msg, char_u *arg);
99
int parse_command_modifiers(exarg_T *eap, char **errormsg, int skip_only);
1010
void undo_cmdmod(exarg_T *eap, int save_msg_scroll);

src/proto/ex_getln.pro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ char *get_text_locked_msg(void);
99
int text_locked(void);
1010
int curbuf_locked(void);
1111
int allbuf_locked(void);
12-
char_u *getexline(int c, void *cookie, int indent, int do_concat);
13-
char_u *getexmodeline(int promptc, void *cookie, int indent, int do_concat);
12+
char_u *getexline(int c, void *cookie, int indent, getline_opt_T options);
13+
char_u *getexmodeline(int promptc, void *cookie, int indent, getline_opt_T options);
1414
int cmdline_overstrike(void);
1515
int cmdline_at_end(void);
1616
colnr_T cmdline_getvcol_cursor(void);

src/proto/scriptfile.pro

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ void scriptnames_slash_adjust(void);
2929
char_u *get_scriptname(scid_T id);
3030
void free_scriptnames(void);
3131
void free_autoload_scriptnames(void);
32-
linenr_T get_sourced_lnum(char_u *(*fgetline)(int, void *, int, int), void *cookie);
33-
char_u *getsourceline(int c, void *cookie, int indent, int do_concat);
32+
linenr_T get_sourced_lnum(char_u *(*fgetline)(int, void *, int, getline_opt_T), void *cookie);
33+
char_u *getsourceline(int c, void *cookie, int indent, getline_opt_T options);
3434
void ex_scriptencoding(exarg_T *eap);
3535
void ex_scriptversion(exarg_T *eap);
3636
void ex_finish(exarg_T *eap);
3737
void do_finish(exarg_T *eap, int reanimate);
38-
int source_finished(char_u *(*fgetline)(int, void *, int, int), void *cookie);
38+
int source_finished(char_u *(*fgetline)(int, void *, int, getline_opt_T), void *cookie);
3939
char_u *autoload_name(char_u *name);
4040
int script_autoload(char_u *name, int reload);
4141
/* vim: set ft=c : */

src/proto/userfunc.pro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void ex_call(exarg_T *eap);
4646
int do_return(exarg_T *eap, int reanimate, int is_cmd, void *rettv);
4747
void discard_pending_return(void *rettv);
4848
char_u *get_return_cmd(void *rettv);
49-
char_u *get_func_line(int c, void *cookie, int indent, int do_concat);
49+
char_u *get_func_line(int c, void *cookie, int indent, getline_opt_T options);
5050
int func_has_ended(void *cookie);
5151
int func_has_abort(void *cookie);
5252
dict_T *make_partial(dict_T *selfdict_in, typval_T *rettv);

0 commit comments

Comments
 (0)