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

platform::New will crash or do other bad things on allocation failure #4998

Closed
bzbarsky-apple opened this issue Feb 24, 2021 · 0 comments · Fixed by #5008
Closed

platform::New will crash or do other bad things on allocation failure #4998

bzbarsky-apple opened this issue Feb 24, 2021 · 0 comments · Fixed by #5008
Assignees

Comments

@bzbarsky-apple
Copy link
Contributor

Problem

platform::New looks like this:

inline T * New(Args &&... args)
{
    return new (MemoryAlloc(sizeof(T))) T(std::forward<Args>(args)...);
}

but MemoryAlloc can return null.

Proposed Solution

Add a null-check, return null if MemoryAlloc returns null.

@kpschoedel @andy31415

@kpschoedel kpschoedel self-assigned this Feb 24, 2021
kpschoedel added a commit to kpschoedel/connectedhomeip that referenced this issue Feb 24, 2021
#### Problem

`Platform::New()` uses placment `new` into a possibly-null pointer.

#### Summary of Changes

Check it.

Fixes project-chip#4998 platform::New will crash or do other bad things on allocation failure
andy31415 pushed a commit that referenced this issue Feb 25, 2021
#### Problem

`Platform::New()` uses placment `new` into a possibly-null pointer.

#### Summary of Changes

Check it.

Fixes #4998 platform::New will crash or do other bad things on allocation failure
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 a pull request may close this issue.

2 participants