From 335f3cc6d6e7f8f39f56b06fc26c7e4a4e1ff6bb Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Mon, 5 May 2014 00:34:19 +0200 Subject: [PATCH] Use rb_enc_str_new instead of rb_enc_str_new_cstr. The latter in combination with strndup() would leak large amounts of memory. --- ext/liboga/lexer.rl | 2 +- ext/liboga/liboga.h | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/ext/liboga/lexer.rl b/ext/liboga/lexer.rl index 01b2f82..866cd3a 100644 --- a/ext/liboga/lexer.rl +++ b/ext/liboga/lexer.rl @@ -13,7 +13,7 @@ void oga_xml_lexer_callback( ) { int length = te - ts; - VALUE value = rb_enc_str_new_cstr(strndup(ts, length), encoding); + VALUE value = rb_enc_str_new(ts, length, encoding); VALUE method = rb_intern(name); rb_funcall(self, method, 1, value); diff --git a/ext/liboga/liboga.h b/ext/liboga/liboga.h index 6f3c0af..9d81457 100644 --- a/ext/liboga/liboga.h +++ b/ext/liboga/liboga.h @@ -3,7 +3,6 @@ #include #include -#include #include #include