summaryrefslogtreecommitdiff
path: root/regcomp.c
diff options
context:
space:
mode:
authornaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-25 04:21:31 (GMT)
committernaruse <naruse@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2016-05-25 04:21:31 (GMT)
commit8c2ddab57a74377c108c3a5a58d2580f063d114b (patch)
tree41e8728c581d32b76e9c54cc129c8e8bbbb6f708 /regcomp.c
parentef6405f71cbc73864a4ee4a46c9ab6d5ccd16959 (diff)
* regcomp.c (compile_length_tree): return error code immediately
if compile_length_tree raised error [Bug #12418] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55154 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'regcomp.c')
-rw-r--r--regcomp.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/regcomp.c b/regcomp.c
index 23cb0ea..34b37f8 100644
--- a/regcomp.c
+++ b/regcomp.c
@@ -1592,13 +1592,15 @@ compile_length_tree(Node* node, regex_t* reg)
case NT_ALT:
{
- int n;
-
- n = r = 0;
+ int n = 0;
+ len = 0;
do {
- r += compile_length_tree(NCAR(node), reg);
- n++;
+ r = compile_length_tree(NCAR(node), reg);
+ if (r < 0) return r;
+ len += r;
+ n++;
} while (IS_NOT_NULL(node = NCDR(node)));
+ r = len;
r += (SIZE_OP_PUSH + SIZE_OP_JUMP) * (n - 1);
}
break;