Skip to content

Conversation

@hintjens
Copy link
Member

@hintjens hintjens commented Dec 8, 2012

Was breaking systematically since it depended on caller to strdup passed values; omitting this created a hard-to-find error. Now the insert/update methods all duplicate the passed value/item for dynamic containers. If callers also duplicate the item the result is a dangling allocation, which is easy to find.

* zhash duplicates item value if container has autofree set
* zlist duplicates item if container has autofree set

This is to get around anti-pattern where caller is responsible for strdup,
and forgetting it causes a double-free. It's easier to detect a dangling
allocation than a double-free.
felipecruz pushed a commit that referenced this pull request Dec 8, 2012
Fixed list/hash autofree strategy
@felipecruz felipecruz merged commit 799a880 into zeromq:master Dec 8, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants