Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

brk_pool_node_new: realloc() in brk_shot_reuse() can fail #24

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

marcmutz
Copy link

Handle failure of realloc() in brk_shot_reuse(), which requires adding a return value to brk_shot_reuse() and handling it in brk_pool_new_node().

If brk_shot_reuse() fails, try allocating a new node. Yes, if realloc() failed, a following malloc() will likely fail, too, but this way the error at least propagates up the call chain.

To keep the logic clean, factor the old if (env->free_list) code into a separate function brk_pool_node_new_from_free_list().

Fixes #23.

Handle failure of realloc() in brk_shot_reuse(), which requires adding
a return value to brk_shot_reuse() and handling it in
brk_pool_new_node().

If brk_shot_reuse() fails, try allocating a new node. Yes, if
realloc() failed, a following malloc() will likely fail, too, but this
way the error at least propagates up the call chain.

To keep the logic clean, factor the old if (env->free_list) code into
a separate function brk_pool_node_new_from_free_list().

Fixes tlwg#23.
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.

brk_shot_reuse doesn't check the return from realloc()
1 participant