Use rb_enc_str_new instead of rb_enc_str_new_cstr.

The latter in combination with strndup() would leak large amounts of memory.
This commit is contained in:
Yorick Peterse 2014-05-05 00:34:19 +02:00
parent 2689d3f65a
commit 335f3cc6d6
2 changed files with 1 additions and 2 deletions

View File

@ -13,7 +13,7 @@ void oga_xml_lexer_callback(
) )
{ {
int length = te - ts; 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); VALUE method = rb_intern(name);
rb_funcall(self, method, 1, value); rb_funcall(self, method, 1, value);

View File

@ -3,7 +3,6 @@
#include <ruby.h> #include <ruby.h>
#include <ruby/encoding.h> #include <ruby/encoding.h>
#include <string.h>
#include <malloc.h> #include <malloc.h>
#include <stdio.h> #include <stdio.h>