librb: dictionary_add mishandles replacing elements

This can only happen with soft asserts otherwise it will crash instead.

Nothing currently uses the return value of rb_dictionary_add.
This commit is contained in:
Simon Arlott 2017-08-06 18:37:20 +01:00
parent f06b5e9c53
commit 1272b289e6
No known key found for this signature in database
GPG key ID: C8975F2043CA5D24

View file

@ -272,7 +272,7 @@ rb_dictionary_retune(rb_dictionary *dict, const void *key)
* Side Effects: * Side Effects:
* - a node is linked to the dictionary tree * - a node is linked to the dictionary tree
*/ */
static void static rb_dictionary_element *
rb_dictionary_link(rb_dictionary *dict, rb_dictionary_link(rb_dictionary *dict,
rb_dictionary_element *delem) rb_dictionary_element *delem)
{ {
@ -334,8 +334,11 @@ rb_dictionary_link(rb_dictionary *dict,
dict->count--; dict->count--;
rb_free(delem); rb_free(delem);
delem = dict->root;
} }
} }
return delem;
} }
/* /*
@ -686,9 +689,7 @@ rb_dictionary_element *rb_dictionary_add(rb_dictionary *dict, const void *key, v
delem->key = key; delem->key = key;
delem->data = data; delem->data = data;
rb_dictionary_link(dict, delem); return rb_dictionary_link(dict, delem);
return delem;
} }
/* /*