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

refactor(ffi): check pointer arguments for NULL #2624

Merged
merged 1 commit into from Aug 18, 2021
Merged

Conversation

seanmonstar
Copy link
Member

This changes all the extern C functions in hyper::ffi to check passed
pointer arguments for being NULL before trying to use them. Before, we
would just assume the programmer had passed a good pointer, which could
result in segmentation faults. Now:

  • In debug builds, it will assert they aren't null, and so if they are,
    a message identifying the argument name will be printed and then the
    process will crash.
  • In release builds, it will still check for null, but if found, it will
    return early, with a return value indicating failure if the return type
    allows (such as returning NULL, or HYPERE_INVALID_ARG).

Closes #2620

This changes all the extern C functions in `hyper::ffi` to check passed
pointer arguments for being `NULL` before trying to use them. Before, we
would just assume the programmer had passed a good pointer, which could
result in segmentation faults. Now:

- In debug builds, it will assert they aren't null, and so if they are,
  a message identifying the argument name will be printed and then the
  process will crash.
- In release builds, it will still check for null, but if found, it will
  return early, with a return value indicating failure if the return type
  allows (such as returning NULL, or `HYPERE_INVALID_ARG`).
@seanmonstar seanmonstar merged commit 3b26572 into master Aug 18, 2021
@seanmonstar seanmonstar deleted the ffi-non-null branch August 18, 2021 21:15
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.

capi: hyper_waker_wake() accepts NULL pointer only to die a horrible death later on
1 participant