Fix warnings: regexp.c: br_regcomp(): Np dereference: MI.

Problem: Dereference of null pointer @ 1312.
         http://neovim.org/doc/reports/clang/report-b1d09a.html#EndPath

Diagnostic: Multithreading issue.
Rationale : Suggested error path contains two succesive calls to
            `regnext(scan)`, first of which returning nonnull, the
            second one returning null. This can only occur if global
            `reg_toolong` accesed in `regnext()` changes between the
            calls.
Resolution: Use local variable to cache first `regnext(scan)` result.
            Note that this change alters function semantics, as now
            function only issues one call instead of two, reusing the
            result for the second time.
            This shouldn't be a problem, though, as new semantics should
            be in fact be better.
This commit is contained in:
Eliseo Martínez 2014-11-04 15:41:48 +01:00
parent 336aab5eef
commit 22475b5ae8

View File

@ -1297,16 +1297,18 @@ static regprog_T *bt_regcomp(char_u *expr, int re_flags)
r->regstart = (*mb_ptr2char)(OPERAND(scan));
else
r->regstart = *OPERAND(scan);
} else if ((OP(scan) == BOW
|| OP(scan) == EOW
|| OP(scan) == NOTHING
|| OP(scan) == MOPEN + 0 || OP(scan) == NOPEN
|| OP(scan) == MCLOSE + 0 || OP(scan) == NCLOSE)
&& OP(regnext(scan)) == EXACTLY) {
if (has_mbyte)
r->regstart = (*mb_ptr2char)(OPERAND(regnext(scan)));
else
r->regstart = *OPERAND(regnext(scan));
} else if (OP(scan) == BOW
|| OP(scan) == EOW
|| OP(scan) == NOTHING
|| OP(scan) == MOPEN + 0 || OP(scan) == NOPEN
|| OP(scan) == MCLOSE + 0 || OP(scan) == NCLOSE) {
char_u *regnext_scan = regnext(scan);
if (OP(regnext_scan) == EXACTLY) {
if (has_mbyte)
r->regstart = (*mb_ptr2char)(OPERAND(regnext_scan));
else
r->regstart = *OPERAND(regnext_scan);
}
}
/*