diff --git a/ext/nokogiri/xml_document.c b/ext/nokogiri/xml_document.c index 348344c244a..f6bc7ac1ceb 100644 --- a/ext/nokogiri/xml_document.c +++ b/ext/nokogiri/xml_document.c @@ -468,8 +468,6 @@ static VALUE canonicalize(int argc, VALUE* argv, VALUE self) xmlChar **ns; long ns_len, i; - rb_scan_args(argc, argv, "03", &mode, &incl_ns, &with_comments); - xmlDocPtr doc; xmlOutputBufferPtr buf; xmlC14NIsVisibleCallback cb = NULL; @@ -478,6 +476,8 @@ static VALUE canonicalize(int argc, VALUE* argv, VALUE self) VALUE rb_cStringIO; VALUE io; + rb_scan_args(argc, argv, "03", &mode, &incl_ns, &with_comments); + Data_Get_Struct(self, xmlDoc, doc); rb_cStringIO = rb_const_get_at(rb_cObject, rb_intern("StringIO"));