summaryrefslogtreecommitdiff
path: root/ext/-test-/regexp
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-02-20 09:46:12 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-02-20 09:46:12 +0000
commitea940cc4dcff8d6c345d7015eda0bf06671f87e9 (patch)
tree3f80c35e0674ffb0e56ff700aafe4a05983a931c /ext/-test-/regexp
parentf28de8c06a6708995c615d8d07f846bbb3cc9435 (diff)
regparse.c: initialize return values
* regparse.c (parse_char_class): initialize return values before depth limit check. returned values will be freed in callers regardless the error. [ruby-core:79624] [Bug #13234] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57660 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/-test-/regexp')
-rw-r--r--ext/-test-/regexp/extconf.rb3
-rw-r--r--ext/-test-/regexp/init.c11
-rw-r--r--ext/-test-/regexp/parse_depth_limit.c23
3 files changed, 37 insertions, 0 deletions
diff --git a/ext/-test-/regexp/extconf.rb b/ext/-test-/regexp/extconf.rb
new file mode 100644
index 0000000000..ca51178a18
--- /dev/null
+++ b/ext/-test-/regexp/extconf.rb
@@ -0,0 +1,3 @@
+# frozen_string_literal: false
+require_relative "../auto_ext.rb"
+auto_ext
diff --git a/ext/-test-/regexp/init.c b/ext/-test-/regexp/init.c
new file mode 100644
index 0000000000..906abe940f
--- /dev/null
+++ b/ext/-test-/regexp/init.c
@@ -0,0 +1,11 @@
+#include "ruby.h"
+
+#define init(n) {void Init_##n(VALUE klass); Init_##n(klass);}
+
+void
+Init_regexp(void)
+{
+ VALUE mBug = rb_define_module("Bug");
+ VALUE klass = rb_define_class_under(mBug, "Regexp", rb_cRegexp);
+ TEST_INIT_FUNCS(init);
+}
diff --git a/ext/-test-/regexp/parse_depth_limit.c b/ext/-test-/regexp/parse_depth_limit.c
new file mode 100644
index 0000000000..8e08a5c789
--- /dev/null
+++ b/ext/-test-/regexp/parse_depth_limit.c
@@ -0,0 +1,23 @@
+#include <ruby.h>
+#include <ruby/onigmo.h>
+
+static VALUE
+get_parse_depth_limit(VALUE self)
+{
+ unsigned int depth = onig_get_parse_depth_limit();
+ return UINT2NUM(depth);
+}
+
+static VALUE
+set_parse_depth_limit(VALUE self, VALUE depth)
+{
+ onig_set_parse_depth_limit(NUM2UINT(depth));
+ return depth;
+}
+
+void
+Init_parse_depth_limit(VALUE klass)
+{
+ rb_define_singleton_method(klass, "parse_depth_limit", get_parse_depth_limit, 0);
+ rb_define_singleton_method(klass, "parse_depth_limit=", set_parse_depth_limit, 1);
+}