From 44b73c5657b65abee213067d9ff8337b74bf8840 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh Date: Mon, 9 Nov 2026 15:33:16 +0900 Subject: [PATCH] Raise for a scalar too long for libyaml The length of a scalar was cast to int when passed to libyaml, so a string of 2 GiB or longer was truncated or made libyaml copy a wrong length. Use RSTRING_LENINT, which raises for such a string. Co-Authored-By: Claude Opus 5.5 --- ext/psych/psych_emitter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/psych/psych_emitter.c b/ext/psych/psych_emitter.c index afe273d6..dd5ad1b6 100644 --- a/ext/psych/psych_emitter.c +++ b/ext/psych/psych_emitter.c @@ -312,7 +312,7 @@ static VALUE scalar( (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor)), (yaml_char_t *)(NIL_P(tag) ? NULL : StringValueCStr(tag)), (yaml_char_t*)value_ptr, - (int)RSTRING_LEN(value), + RSTRING_LENINT(value), plain ? 1 : 0, quoted ? 1 : 0, (yaml_scalar_style_t)NUM2INT(style)