View Issue Details

IDProjectCategoryView StatusLast Update
0002898GNUnetutil librarypublic2013-12-24 19:54
ReporterFlorian Dold Assigned ToFlorian Dold Due Date
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 16:48

manager   ~0007164

Should just be documented.

Issue History

Date ModifiedUsernameFieldChange
2013-06-19 01:41Florian DoldNew Issue
2013-06-19 16:48Christian GrothoffNote Added: 0007164
2013-06-19 16:48Christian GrothoffAssigned To => Florian Dold
2013-06-19 16:48Christian GrothoffSeverityminor => text
2013-06-19 16:48Christian GrothoffStatusnew => assigned
2013-06-26 00:44Florian DoldStatusassigned => resolved
2013-06-26 00:44Florian DoldResolutionopen => fixed
2013-06-26 07:51Christian GrothoffProduct Version => Git master
2013-06-26 07:51Christian GrothoffFixed in Version => 0.10.0
2013-06-26 07:51Christian GrothoffTarget Version => 0.10.0
2013-12-24 19:54Christian GrothoffStatusresolved => closed