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

Fix GH-14639: Member access within null pointer in ext/spl/spl_observer.c #14849

Closed
wants to merge 1 commit into from

Conversation

nielsdos
Copy link
Member

@nielsdos nielsdos commented Jul 6, 2024

spl_object_storage_attach_handle creates an entry already, but only fills it in at the end with spl_object_storage_create_element which allocates memory. In this case the allocation fails and we're left with a NULL slot. Doing the allocation first isn't an option because we want to check whether the slot is occupied before allocating memory. The simplest solution is to set the entry to NULL and check for a NULL pointer upon destruction.

@nielsdos nielsdos requested a review from Girgias as a code owner July 6, 2024 20:48
@nielsdos nielsdos linked an issue Jul 6, 2024 that may be closed by this pull request
…erver.c

`spl_object_storage_attach_handle` creates an entry already, but only
fills it in at the end with `spl_object_storage_create_element` which
allocates memory. In this case the allocation fails and we're left with
a NULL slot. Doing the allocation first isn't an option because we want
to check whether the slot is occupied before allocating memory.
The simplest solution is to set the entry to NULL and check for a NULL
pointer upon destruction.
Copy link
Member

@Girgias Girgias left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, these memory bailout issues are somewhat annoying :/

@nielsdos
Copy link
Member Author

nielsdos commented Jul 6, 2024

LGTM, these memory bailout issues are somewhat annoying :/

Yeah we seem to hit them a lot lately. And they're a pain to debug (like that Curl one)

@nielsdos nielsdos closed this in 0d4e0c0 Jul 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Member access within null pointer in ext/spl/spl_observer.c
2 participants