Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9502d76

Browse files
committed
Use ruby_strdup with xfree
ruby_strdup is like strdup, but using xmalloc which informs Ruby's GC about the allocation (confusingly by including ruby/util.h strdup is defined into ruby_strdup, but let's use ruby_strdup for clarity).
1 parent 6bed0a9 commit 9502d76

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

ext/better_html_ext/parser.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include <ruby.h>
2+
#include <ruby/util.h>
23
#include <ruby/encoding.h>
34
#include "html_tokenizer.h"
45
#include "parser.h"
@@ -81,7 +82,7 @@ static inline void parser_append_ref(struct token_reference_t *dest, struct toke
8182
static void parser_add_error(struct parser_t *parser, const char *message)
8283
{
8384
REALLOC_N(parser->errors, struct parser_document_error_t, parser->errors_count + 1);
84-
parser->errors[parser->errors_count].message = strdup(message);
85+
parser->errors[parser->errors_count].message = ruby_strdup(message);
8586
parser->errors[parser->errors_count].pos = parser->tk.scan.cursor;
8687
parser->errors[parser->errors_count].mb_pos = parser->tk.scan.mb_cursor;
8788
parser->errors[parser->errors_count].line_number = parser->doc.line_number;

0 commit comments

Comments
 (0)