patch 9.0.0742: reading past end of the line when compiling a function
Problem:    Reading past end of the line when compiling a function with
            errors.
Solution:   Do not return an invalid pointer.  Fix skipping redirection.
			
			
This commit is contained in:
		| @ -2412,34 +2412,37 @@ compile_redir(char_u *line, exarg_T *eap, cctx_T *cctx) | ||||
|     { | ||||
| 	if (STRNCMP(arg, "END", 3) == 0) | ||||
| 	{ | ||||
| 	    if (lhs->lhs_append) | ||||
| 	    if (cctx->ctx_skip != SKIP_YES) | ||||
| 	    { | ||||
| 		// First load the current variable value. | ||||
| 		if (compile_load_lhs_with_index(lhs, lhs->lhs_whole, | ||||
| 		if (lhs->lhs_append) | ||||
| 		{ | ||||
| 		    // First load the current variable value. | ||||
| 		    if (compile_load_lhs_with_index(lhs, lhs->lhs_whole, | ||||
| 								 cctx) == FAIL) | ||||
| 		    return NULL; | ||||
| 	    } | ||||
| 			return NULL; | ||||
| 		} | ||||
|  | ||||
| 	    // Gets the redirected text and put it on the stack, then store it | ||||
| 	    // in the variable. | ||||
| 	    generate_instr_type(cctx, ISN_REDIREND, &t_string); | ||||
| 		// Gets the redirected text and put it on the stack, then store | ||||
| 		// it in the variable. | ||||
| 		generate_instr_type(cctx, ISN_REDIREND, &t_string); | ||||
|  | ||||
| 	    if (lhs->lhs_append) | ||||
| 		generate_CONCAT(cctx, 2); | ||||
| 		if (lhs->lhs_append) | ||||
| 		    generate_CONCAT(cctx, 2); | ||||
|  | ||||
| 	    if (lhs->lhs_has_index) | ||||
| 	    { | ||||
| 		// Use the info in "lhs" to store the value at the index in the | ||||
| 		// list or dict. | ||||
| 		if (compile_assign_unlet(lhs->lhs_whole, lhs, TRUE, | ||||
| 		if (lhs->lhs_has_index) | ||||
| 		{ | ||||
| 		    // Use the info in "lhs" to store the value at the index in | ||||
| 		    // the list or dict. | ||||
| 		    if (compile_assign_unlet(lhs->lhs_whole, lhs, TRUE, | ||||
| 						      &t_string, cctx) == FAIL) | ||||
| 			return NULL; | ||||
| 		} | ||||
| 		else if (generate_store_lhs(cctx, lhs, -1, FALSE) == FAIL) | ||||
| 		    return NULL; | ||||
| 	    } | ||||
| 	    else if (generate_store_lhs(cctx, lhs, -1, FALSE) == FAIL) | ||||
| 		return NULL; | ||||
|  | ||||
| 	    VIM_CLEAR(lhs->lhs_name); | ||||
| 	    VIM_CLEAR(lhs->lhs_whole); | ||||
| 		VIM_CLEAR(lhs->lhs_name); | ||||
| 		VIM_CLEAR(lhs->lhs_whole); | ||||
| 	    } | ||||
| 	    return arg + 3; | ||||
| 	} | ||||
| 	emsg(_(e_cannot_nest_redir)); | ||||
| @ -2465,13 +2468,20 @@ compile_redir(char_u *line, exarg_T *eap, cctx_T *cctx) | ||||
| 	if (need_type(&t_string, lhs->lhs_member_type, | ||||
| 					    -1, 0, cctx, FALSE, FALSE) == FAIL) | ||||
| 	    return NULL; | ||||
| 	generate_instr(cctx, ISN_REDIRSTART); | ||||
| 	lhs->lhs_append = append; | ||||
| 	if (lhs->lhs_has_index) | ||||
| 	if (cctx->ctx_skip == SKIP_YES) | ||||
| 	{ | ||||
| 	    lhs->lhs_whole = vim_strnsave(arg, lhs->lhs_varlen_total); | ||||
| 	    if (lhs->lhs_whole == NULL) | ||||
| 		return NULL; | ||||
| 	    VIM_CLEAR(lhs->lhs_name); | ||||
| 	} | ||||
| 	else | ||||
| 	{ | ||||
| 	    generate_instr(cctx, ISN_REDIRSTART); | ||||
| 	    lhs->lhs_append = append; | ||||
| 	    if (lhs->lhs_has_index) | ||||
| 	    { | ||||
| 		lhs->lhs_whole = vim_strnsave(arg, lhs->lhs_varlen_total); | ||||
| 		if (lhs->lhs_whole == NULL) | ||||
| 		    return NULL; | ||||
| 	    } | ||||
| 	} | ||||
|  | ||||
| 	return arg + lhs->lhs_varlen_total; | ||||
|  | ||||
		Reference in New Issue
	
	Block a user