On 14 October 2012 14:08, Tim Hardeck <thard...@suse.de> wrote:
> When calling QTAILQ_REMOVE or QLIST_REMOVE on an unitialized list
> QEMU segfaults.
>
> Check for this case specifically on item removal.

Incidentally, this commit message is inaccurate -- you can't
call the _REMOVE macros on a list (uninitialised or otherwise)
because they take the list item, not the list itself. The
case you are trying to guard against here is attempting to
remove an item which never got inserted into the list in
the first place.

However this check doesn't catch all cases, because (a)
there's no guarantee that the list element pointers get
initialised to NULL and (b) removing an item from the
list doesn't clear the pointers either, so this check
still wouldn't catch "removed the item twice". Better
just to accept that the semantics are "you can only use
the _REMOVE macro on items that are actually in the list",
I think.

-- PMM

Reply via email to