llcache: Ensure we preserve iteratorness when sending messages

In order to prevent a problem where iterating causes an abort
which causes an iteration which clears the iteratorness of a
user allowing it to delete itself causing a segfault, preserve
the iteratorness when iterating in send_message

Signed-off-by: Daniel Silverstone <dsilvers@digital-scurf.org>
This commit is contained in:
Daniel Silverstone 2019-08-02 16:57:55 +01:00
parent f7d97d6483
commit 4421d1bab6

View File

@ -393,6 +393,7 @@ static nserror llcache_send_event_to_users(llcache_object *object,
user = object->users;
while (user != NULL) {
bool was_target = user->iterator_target;
user->iterator_target = true;
error = user->handle->cb(user->handle, event,
@ -400,7 +401,7 @@ static nserror llcache_send_event_to_users(llcache_object *object,
next_user = user->next;
user->iterator_target = false;
user->iterator_target = was_target;
if (user->queued_for_delete) {
llcache_object_remove_user(object, user);