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: Prevent crash on OOM in error copy #1183

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Commits on Feb 24, 2023

  1. Add NUL character at the end of copied error message

    C++ error message returned by `what` must be NUL-terminated. However,
    the current copy function only copied the characters, but didn't add
    the NUL. Allocate one more byte and set it to NUL.
    schreter committed Feb 24, 2023
    Configuration menu
    Copy the full SHA
    c000e9c View commit details
    Browse the repository at this point in the history

Commits on Feb 26, 2023

  1. Fix: Prevent crash on OOM in error copy

    When the error message is copied, the allocation may fail. This would
    terminate the process, since it's called from a `noexcept` function.
    
    Make the allocation `nothrow` and handle `nullptr` in `what()` method
    appropriately, returning a generic message saying that the message
    cannot be allocated.
    
    This also prevents a crash if `what()` is called on a moved object
    (which is technically UB, but still better not to crash).
    schreter committed Feb 26, 2023
    Configuration menu
    Copy the full SHA
    eec29dc View commit details
    Browse the repository at this point in the history