diff --git a/ext/psych/psych_emitter.c b/ext/psych/psych_emitter.c index 0c5875f3..3b7a367b 100644 --- a/ext/psych/psych_emitter.c +++ b/ext/psych/psych_emitter.c @@ -304,11 +304,12 @@ static VALUE scalar( tag = rb_str_export_to_enc(tag, encoding); } + const char *value_ptr = StringValuePtr(value); yaml_scalar_event_initialize( &event, (yaml_char_t *)(NIL_P(anchor) ? NULL : StringValueCStr(anchor)), (yaml_char_t *)(NIL_P(tag) ? NULL : StringValueCStr(tag)), - (yaml_char_t*)StringValuePtr(value), + (yaml_char_t*)value_ptr, (int)RSTRING_LEN(value), plain ? 1 : 0, quoted ? 1 : 0,