#563227 libxml2: xmlListSort frees original list

Package:
libxml2
Source:
libxml2
Description:
GNOME XML library
Submitter:
Josh Triplett
Date:
2021-07-05 18:33:04 UTC
Severity:
normal
Tags:
#563227#3
Date:
2010-01-01 07:12:20 UTC
From:
To:
Having had some trouble trying to use xmlListSort, I took a look at the
implementation.  It seems to work by copying the original list, clearing
the original list, and then inserting each element from the copy into
the original.  Apart from inefficiency, this has one major bug: clearing
the original list calls the user-supplied deallocator on each element,
making those elements unusable in the copy.  This resulted in accesses
to freed memory, easily found via valgrind.

- Josh Triplett