From 229e346ebc9624afaba16d3da3e447030c858fff Mon Sep 17 00:00:00 2001 From: Tom Black Date: Fri, 5 Oct 2018 22:33:12 -0700 Subject: Fix MRuby crash when using default font --- ext/ruby2d/ruby2d.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'ext') diff --git a/ext/ruby2d/ruby2d.c b/ext/ruby2d/ruby2d.c index cf89990..885bf5c 100644 --- a/ext/ruby2d/ruby2d.c +++ b/ext/ruby2d/ruby2d.c @@ -466,6 +466,12 @@ static R_VAL ruby2d_text_ext_init(R_VAL self) { #endif S2D_Log(S2D_INFO, "Init text: %s", RSTRING_PTR(r_iv_get(self, "@text"))); + // Trim the font file string to its actual length on MRuby + #if MRUBY + mrb_value s = r_iv_get(self, "@font"); + mrb_str_resize(mrb, s, RSTRING_LEN(s)); + #endif + S2D_Text *txt = S2D_CreateText( RSTRING_PTR(r_iv_get(self, "@font")), RSTRING_PTR(r_iv_get(self, "@text")), -- cgit v1.2.3