Element extend() method does not check for inner elements sanity

Bug #712388 reported by Alan Franzoni
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
lxml
Fix Released
Medium
scoder

Bug Description

The extend() methods does not check for inner elements sanity before appending, contrarily to the append() method. This makes it pretty easy to cause a segfault instead of just raising an exception:

from lxml.etree import Element
e = Element("foo")
e.extend([None])
Segmentation fault

See:
http://bazaar.launchpad.net/~vcs-imports/lxml/trunk/view/head:/src/lxml/lxml.etree.pyx#L718

A check should be implemented to verify the element is fine - I don't know how Cython works, if the public append() method could be called instead of _appendChild that would suffice.

System info:

Ubuntu Maverick 64 bit:

Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56)
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> from lxml import etree
>>>
>>> print("%-20s: %s" % ('Python', sys.version_info))
Python : (2, 6, 6, 'final', 0)
>>> print("%-20s: %s" % ('lxml.etree', etree.LXML_VERSION))
lxml.etree : (2, 2, 6, 0)
>>> print("%-20s: %s" % ('libxml used', etree.LIBXML_VERSION))
libxml used : (2, 7, 7)
>>> print("%-20s: %s" % ('libxml compiled', etree.LIBXML_COMPILED_VERSION))
libxml compiled : (2, 7, 6)
>>> print("%-20s: %s" % ('libxslt used', etree.LIBXSLT_VERSION))
libxslt used : (1, 1, 26)
>>> print("%-20s: %s" % ('libxslt compiled', etree.LIBXSLT_COMPILED_VERSION))
libxslt compiled : (1, 1, 26)
>>>

description: updated
Revision history for this message
scoder (scoder) wrote :

Already fixed in the latest 2.3 release.

Changed in lxml:
assignee: nobody → Stefan Behnel (scoder)
importance: Undecided → High
milestone: none → 2.3
status: New → Fix Released
importance: High → Medium
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.