mirror of
https://github.com/vim/vim.git
synced 2025-09-30 04:44:14 -04:00
patch 8.2.4783: Coverity warns for leaking memory
Problem: Coverity warns for leaking memory. Solution: Use another strategy freeing "theline".
This commit is contained in:
@@ -684,7 +684,7 @@ eval_all_expr_in_str(char_u *str)
|
|||||||
list_T *
|
list_T *
|
||||||
heredoc_get(exarg_T *eap, char_u *cmd, int script_get)
|
heredoc_get(exarg_T *eap, char_u *cmd, int script_get)
|
||||||
{
|
{
|
||||||
char_u *theline;
|
char_u *theline = NULL;
|
||||||
char_u *marker;
|
char_u *marker;
|
||||||
list_T *l;
|
list_T *l;
|
||||||
char_u *p;
|
char_u *p;
|
||||||
@@ -776,6 +776,7 @@ heredoc_get(exarg_T *eap, char_u *cmd, int script_get)
|
|||||||
int mi = 0;
|
int mi = 0;
|
||||||
int ti = 0;
|
int ti = 0;
|
||||||
|
|
||||||
|
vim_free(theline);
|
||||||
theline = eap->getline(NUL, eap->cookie, 0, FALSE);
|
theline = eap->getline(NUL, eap->cookie, 0, FALSE);
|
||||||
if (theline == NULL)
|
if (theline == NULL)
|
||||||
{
|
{
|
||||||
@@ -789,18 +790,12 @@ heredoc_get(exarg_T *eap, char_u *cmd, int script_get)
|
|||||||
&& STRNCMP(theline, *eap->cmdlinep, marker_indent_len) == 0)
|
&& STRNCMP(theline, *eap->cmdlinep, marker_indent_len) == 0)
|
||||||
mi = marker_indent_len;
|
mi = marker_indent_len;
|
||||||
if (STRCMP(marker, theline + mi) == 0)
|
if (STRCMP(marker, theline + mi) == 0)
|
||||||
{
|
|
||||||
vim_free(theline);
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
// If expression evaluation failed in the heredoc, then skip till the
|
// If expression evaluation failed in the heredoc, then skip till the
|
||||||
// end marker.
|
// end marker.
|
||||||
if (eval_failed)
|
if (eval_failed)
|
||||||
{
|
|
||||||
vim_free(theline);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
if (text_indent_len == -1 && *theline != NUL)
|
if (text_indent_len == -1 && *theline != NUL)
|
||||||
{
|
{
|
||||||
@@ -827,7 +822,6 @@ heredoc_get(exarg_T *eap, char_u *cmd, int script_get)
|
|||||||
if (str == NULL)
|
if (str == NULL)
|
||||||
{
|
{
|
||||||
// expression evaluation failed
|
// expression evaluation failed
|
||||||
vim_free(theline);
|
|
||||||
eval_failed = TRUE;
|
eval_failed = TRUE;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -837,8 +831,8 @@ heredoc_get(exarg_T *eap, char_u *cmd, int script_get)
|
|||||||
|
|
||||||
if (list_append_string(l, str, -1) == FAIL)
|
if (list_append_string(l, str, -1) == FAIL)
|
||||||
break;
|
break;
|
||||||
vim_free(theline);
|
|
||||||
}
|
}
|
||||||
|
vim_free(theline);
|
||||||
vim_free(text_indent);
|
vim_free(text_indent);
|
||||||
|
|
||||||
if (eval_failed)
|
if (eval_failed)
|
||||||
|
@@ -746,6 +746,8 @@ static char *(features[]) =
|
|||||||
|
|
||||||
static int included_patches[] =
|
static int included_patches[] =
|
||||||
{ /* Add new patch number below this line */
|
{ /* Add new patch number below this line */
|
||||||
|
/**/
|
||||||
|
4783,
|
||||||
/**/
|
/**/
|
||||||
4782,
|
4782,
|
||||||
/**/
|
/**/
|
||||||
|
Reference in New Issue
Block a user