From efc459348003ec9a544c10e69556aff421c8b6b9 Mon Sep 17 00:00:00 2001 From: Oskar Eichler Date: Sat, 29 Aug 2026 21:57:49 +0200 Subject: [PATCH] Honor exception false for strings with null bytes --- ext/bigdecimal/bigdecimal.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ext/bigdecimal/bigdecimal.c b/ext/bigdecimal/bigdecimal.c index 99bd9f06..49a340c4 100644 --- a/ext/bigdecimal/bigdecimal.c +++ b/ext/bigdecimal/bigdecimal.c @@ -2845,6 +2845,7 @@ rb_cstr_convert_to_BigDecimal(const char *c_str, int raise_exception) static inline VALUE rb_str_convert_to_BigDecimal(VALUE val, int raise_exception) { + if (!raise_exception && memchr(RSTRING_PTR(val), '\0', RSTRING_LEN(val))) return Qnil; const char *c_str = StringValueCStr(val); return rb_cstr_convert_to_BigDecimal(c_str, raise_exception); }