From b51b22513f6a2a514a9e614e7a9f6e0df6c0c985 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Mon, 24 Oct 2022 18:03:26 +0900 Subject: Fix per-instance Regexp timeout (#6621) Fix per-instance Regexp timeout This makes it follow what was decided in [Bug #19055]: * `Regexp.new(str, timeout: nil)` should respect the global timeout * `Regexp.new(str, timeout: huge_val)` should use the maximum value that can be represented in the internal representation * `Regexp.new(str, timeout: 0 or negative value)` should raise an error --- hrtime.h | 1 + 1 file changed, 1 insertion(+) (limited to 'hrtime.h') diff --git a/hrtime.h b/hrtime.h index 80aff5deb3..7ed4e6b04c 100644 --- a/hrtime.h +++ b/hrtime.h @@ -206,6 +206,7 @@ double2hrtime(rb_hrtime_t *hrt, double d) const double TIMESPEC_SEC_MAX_PLUS_ONE = 2.0 * (TIMESPEC_SEC_MAX_as_double / 2.0 + 1.0); if (TIMESPEC_SEC_MAX_PLUS_ONE <= d) { + *hrt = RB_HRTIME_MAX; return NULL; } else if (d <= 0) { -- cgit v1.2.1