mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Fix warnings: syntax.c: get_id_list(): Double free: FP.
Problem : Double free @ 5213. Diagnostic : False positive. Rationale : Suggested error path contains two consecutive invocations of `ends_excmd(*p)` having different results, which is not possible. First invocation is before the while loop. Second invocation is the while loop condition itsef. Resolution : Refactor while loop into do-while loop. That removes the impossible path from analysis, and, in addition, is a bit more efficient.
This commit is contained in:
parent
ce9c4e9a6f
commit
fcd5a8643c
@ -31,6 +31,7 @@
|
|||||||
#include "nvim/ex_getln.h"
|
#include "nvim/ex_getln.h"
|
||||||
#include "nvim/fileio.h"
|
#include "nvim/fileio.h"
|
||||||
#include "nvim/fold.h"
|
#include "nvim/fold.h"
|
||||||
|
#include "nvim/func_attr.h"
|
||||||
#include "nvim/getchar.h"
|
#include "nvim/getchar.h"
|
||||||
#include "nvim/hardcopy.h"
|
#include "nvim/hardcopy.h"
|
||||||
#include "nvim/if_cscope.h"
|
#include "nvim/if_cscope.h"
|
||||||
@ -4025,7 +4026,7 @@ static void ex_blast(exarg_T *eap)
|
|||||||
goto_buffer(eap, DOBUF_LAST, BACKWARD, 0);
|
goto_buffer(eap, DOBUF_LAST, BACKWARD, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
int ends_excmd(int c)
|
int ends_excmd(int c) FUNC_ATTR_CONST
|
||||||
{
|
{
|
||||||
return c == NUL || c == '|' || c == '"' || c == '\n';
|
return c == NUL || c == '|' || c == '"' || c == '\n';
|
||||||
}
|
}
|
||||||
|
@ -5106,7 +5106,7 @@ get_id_list (
|
|||||||
* parse the arguments after "contains"
|
* parse the arguments after "contains"
|
||||||
*/
|
*/
|
||||||
count = 0;
|
count = 0;
|
||||||
while (!ends_excmd(*p)) {
|
do {
|
||||||
for (end = p; *end && !vim_iswhite(*end) && *end != ','; ++end)
|
for (end = p; *end && !vim_iswhite(*end) && *end != ','; ++end)
|
||||||
;
|
;
|
||||||
name = xmalloc((int)(end - p + 3)); /* leave room for "^$" */
|
name = xmalloc((int)(end - p + 3)); /* leave room for "^$" */
|
||||||
@ -5199,7 +5199,7 @@ get_id_list (
|
|||||||
if (*p != ',')
|
if (*p != ',')
|
||||||
break;
|
break;
|
||||||
p = skipwhite(p + 1); /* skip comma in between arguments */
|
p = skipwhite(p + 1); /* skip comma in between arguments */
|
||||||
}
|
} while (!ends_excmd(*p));
|
||||||
if (failed)
|
if (failed)
|
||||||
break;
|
break;
|
||||||
if (round == 1) {
|
if (round == 1) {
|
||||||
|
Loading…
Reference in New Issue
Block a user