All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hashmap: Fix removing last entry in l_hashmap_foreach_remove
@ 2018-10-20  2:33 Andrew Zaborowski
  2018-10-20 16:02 ` Denis Kenzior
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Zaborowski @ 2018-10-20  2:33 UTC (permalink / raw)
  To: ell

[-- Attachment #1: Type: text/plain, Size: 626 bytes --]

When the last entry in a bucket with 2 or more entries was removed
the loop would roll over and iterate over the remaining entries for a
second time (then stop), add missing check.
---
 ell/hashmap.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/ell/hashmap.c b/ell/hashmap.c
index ee11d31..061080b 100644
--- a/ell/hashmap.c
+++ b/ell/hashmap.c
@@ -607,6 +607,8 @@ LIB_EXPORT unsigned int l_hashmap_foreach_remove(struct l_hashmap *hashmap,
 				free_key(hashmap, entry->key);
 				l_free(entry);
 				entry = prev->next;
+				if (entry == head)
+					break;
 				continue;
 			}
 
-- 
2.19.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] hashmap: Fix removing last entry in l_hashmap_foreach_remove
  2018-10-20  2:33 [PATCH] hashmap: Fix removing last entry in l_hashmap_foreach_remove Andrew Zaborowski
@ 2018-10-20 16:02 ` Denis Kenzior
  0 siblings, 0 replies; 2+ messages in thread
From: Denis Kenzior @ 2018-10-20 16:02 UTC (permalink / raw)
  To: ell

[-- Attachment #1: Type: text/plain, Size: 388 bytes --]

Hi Andrew,

On 10/19/2018 09:33 PM, Andrew Zaborowski wrote:
> When the last entry in a bucket with 2 or more entries was removed
> the loop would roll over and iterate over the remaining entries for a
> second time (then stop), add missing check.
> ---
>   ell/hashmap.c | 2 ++
>   1 file changed, 2 insertions(+)
> 

Hah, good catch.  Applied, thanks.

Regards,
-Denis


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-10-20 16:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-20  2:33 [PATCH] hashmap: Fix removing last entry in l_hashmap_foreach_remove Andrew Zaborowski
2018-10-20 16:02 ` Denis Kenzior

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.