Skip to content

Commit 0d07de8

Browse files
committed
Fix xpath GC crash and add rdoc development dependency
- Guard xpath object mark function against NULL _private pointer to prevent "try to mark T_NONE" crash during GC stress - Add rdoc as development dependency (removed from default gems in Ruby 4.0)
1 parent 7ea86ad commit 0d07de8

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

ext/libxml/ruby_xml_document.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void rxml_document_free(void* data)
7171
const rb_data_type_t rxml_document_data_type = {
7272
.wrap_struct_name = "LibXML::XML::Document",
7373
.function = { .dmark = NULL, .dfree = rxml_document_free },
74-
.flags = RUBY_TYPED_FREE_IMMEDIATELY,
74+
.flags = 0,
7575
};
7676

7777
VALUE rxml_document_wrap(xmlDocPtr xdoc)

ext/libxml/ruby_xml_xpath_object.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ static void rxml_xpath_object_mark(void *data)
6868
static const rb_data_type_t rxml_xpath_object_data_type = {
6969
.wrap_struct_name = "LibXML::XML::XPath::Object",
7070
.function = { .dmark = rxml_xpath_object_mark, .dfree = rxml_xpath_object_free },
71-
.flags = RUBY_TYPED_FREE_IMMEDIATELY,
71+
.flags = 0,
7272
};
7373

7474
VALUE rxml_xpath_object_wrap(xmlDocPtr xdoc, xmlXPathObjectPtr xpop)
@@ -78,7 +78,7 @@ VALUE rxml_xpath_object_wrap(xmlDocPtr xdoc, xmlXPathObjectPtr xpop)
7878

7979
/* Make sure Ruby's GC can find the array in the stack */
8080
VALUE nsnodes = rb_ary_new();
81-
rxpopp->xdoc =xdoc;
81+
rxpopp->xdoc = xdoc;
8282
rxpopp->xpop = xpop;
8383

8484
/* Find all the extra namespace nodes and wrap them. */

0 commit comments

Comments
 (0)