From 1400a859cea32ef19615d7f8ff8b2ab26f1e1eae Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Sun, 28 Sep 2014 22:28:55 +0200 Subject: [PATCH] Make sure C strings always end with a NULL. Haven't bumped into any problems just yet. However, in theory all sorts of evil could happen here. Which is part of the problem of C: so much shit is undefined behaviour that you can take a single step and fall in 15 holes at the same time. In theory, because nobody bothered to actually specify it properly. --- ext/c/lexer.rl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/c/lexer.rl b/ext/c/lexer.rl index 43a135c..e70c9c8 100644 --- a/ext/c/lexer.rl +++ b/ext/c/lexer.rl @@ -78,7 +78,7 @@ VALUE oga_xml_lexer_advance(VALUE self, VALUE data_block) /* Make sure that all data passed back to Ruby has the proper encoding. */ rb_encoding *encoding = rb_enc_get(data_block); - char *data_str_val = StringValuePtr(data_block); + char *data_str_val = StringValueCStr(data_block); const char *p = data_str_val; const char *pe = data_str_val + strlen(data_str_val);