aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/regexp.c
diff options
context:
space:
mode:
authorEliseo Martínez <eliseomarmol@gmail.com>2014-11-04 15:41:48 +0100
committerEliseo Martínez <eliseomarmol@gmail.com>2014-11-06 09:51:44 +0100
commit22475b5ae80b5c08115677b9abc5c62258716c08 (patch)
tree724cf7e7a10a0ff7a83daba559d834c2817f2a4f /src/nvim/regexp.c
parent336aab5eef68a493dcd1ddc2dfe6405b6ee7a0a9 (diff)
downloadrneovim-22475b5ae80b5c08115677b9abc5c62258716c08.tar.gz
rneovim-22475b5ae80b5c08115677b9abc5c62258716c08.tar.bz2
rneovim-22475b5ae80b5c08115677b9abc5c62258716c08.zip
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.
Diffstat (limited to 'src/nvim/regexp.c')
-rw-r--r--src/nvim/regexp.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/nvim/regexp.c b/src/nvim/regexp.c
index 4e5ae403d6..93fc5c62ef 100644
--- a/src/nvim/regexp.c
+++ b/src/nvim/regexp.c
@@ -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);
+ }
}
/*