Skip to content

Commit

Permalink
FFI: fixing pointer bug in reader. thanks to Wayne Meissner. closes #59.
Browse files Browse the repository at this point in the history
  • Loading branch information
flavorjones committed May 16, 2009
1 parent cfff9cc commit c4c583a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/nokogiri/ffi/xml/reader.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,9 @@ def attribute(name) # :nodoc:
if attr_ptr.null?
# this section is an attempt to workaround older versions of libxml that
# don't handle namespaces properly in all attribute-and-friends functions
prefix = FFI::MemoryPointer.new :pointer
localname = LibXML.xmlSplitQName2(name, prefix)
prefix_ptr = FFI::MemoryPointer.new :pointer
localname = LibXML.xmlSplitQName2(name, prefix_ptr)
prefix = prefix_ptr.get_pointer(0)
if ! localname.null?
attr_ptr = LibXML.xmlTextReaderLookupNamespace(cstruct, localname.read_string)
LibXML.xmlFree(localname)
Expand All @@ -81,7 +82,7 @@ def attribute(name) # :nodoc:
attr_ptr = LibXML.xmlTextReaderLookupNamespace(cstruct, prefix.read_string)
end
end
LibXML.xmlFree(prefix.read_pointer)
LibXML.xmlFree(prefix)
end
return nil if attr_ptr.null?

Expand Down

0 comments on commit c4c583a

Please sign in to comment.