View Issue Details

IDProjectCategoryView StatusLast Update
0002898GNUnetutil librarypublic2013-12-24 20:54
ReporterFlorian Dold Assigned ToFlorian Dold  
PrioritynormalSeveritytextReproducibilityalways
Status closedResolutionfixed 
Product VersionGit master 
Target Version0.10.0Fixed in Version0.10.0 
Summary0002898: removing a DLL's head can fail
DescriptionRemoving a DLL's head like this

  GNUNET_CONTAINER_DLL_remove (my_head, my_tail, my_head);

can fail.

Without reading the macro's code, one would expect that this simply removes the first element of the list. Instead, a segfault is produced, if the list only has one element.

The relevant part of the macro:

  if ((element)->prev == NULL) \
    (head) = (element)->next; \
  else \
    (element)->prev->next = (element)->next; \
  if ((element)->next == NULL) \
    (tail) = (element)->prev; \
  else \
    (element)->next->prev = (element)->prev; \

Note that the true-branch of the second 'if' causes havoc if 'head' and 'element' alias in a 1-element list: 'element' is a NULL pointer, as 'head' has been assigned to NULL.

If this won't be fixed it should at least be document, as the above code looks innocent enough to be overlooked.
TagsNo tags attached.

Activities

Christian Grothoff

2013-06-19 18:48

manager   ~0007164

Should just be documented.

Issue History

Date Modified Username Field Change
2013-06-19 03:41 Florian Dold New Issue
2013-06-19 18:48 Christian Grothoff Note Added: 0007164
2013-06-19 18:48 Christian Grothoff Assigned To => Florian Dold
2013-06-19 18:48 Christian Grothoff Severity minor => text
2013-06-19 18:48 Christian Grothoff Status new => assigned
2013-06-26 02:44 Florian Dold Status assigned => resolved
2013-06-26 02:44 Florian Dold Resolution open => fixed
2013-06-26 09:51 Christian Grothoff Product Version => Git master
2013-06-26 09:51 Christian Grothoff Fixed in Version => 0.10.0
2013-06-26 09:51 Christian Grothoff Target Version => 0.10.0
2013-12-24 20:54 Christian Grothoff Status resolved => closed