vim-patch:8.2.4703: memory leak in handling 'cinscopedecls'

Problem:    Memory leak in handling 'cinscopedecls'.
Solution:   Free the memory before returning.
cb49a1d934
This commit is contained in:
Tom Praschan 2022-04-08 19:27:48 +02:00
parent 45f62464d3
commit bf39c5fe4f

View File

@ -520,19 +520,22 @@ bool cin_isscopedecl(const char_u *p)
const size_t cinsd_len = STRLEN(curbuf->b_p_cinsd) + 1;
char_u *cinsd_buf = xmalloc(cinsd_len);
bool found = false;
for (char_u *cinsd = curbuf->b_p_cinsd; *cinsd; ) {
const size_t len = copy_option_part(&cinsd, cinsd_buf, cinsd_len, ",");
if (STRNCMP(s, cinsd_buf, len) == 0) {
const char_u *skip = cin_skipcomment(s + len);
if (*skip == ':' && skip[1] != ':') {
return true;
found = true;
break;
}
}
}
xfree(cinsd_buf);
return false;
return found;
}
// Maximum number of lines to search back for a "namespace" line.