Description of the false positive
Fprime is a C++ project targeting embedded systems and is explicitly calling the new(std::nothrow) variant of new.
Because of this, it must check that the return value of new(std::nothrow) is null. The cpp/incorrect-allocation-error-handling incorrectly suggests that the allocation cannot return null, despite the fact that it can. Suggesting the incorrect error handling of memory allocation is dangerous and can lead to serious bugs.
It looks like cpp/incorrect-allocation-error-handling query has logic for handling std::nothrow but isn't successfully matching these calls to new(std::nothrow).
https://lgtm.com/projects/g/nasa/fprime/rev/pr-47d3627dbb3106f32896b17edc48b8829d494566
Description of the false positive
Fprime is a C++ project targeting embedded systems and is explicitly calling the
new(std::nothrow)variant of new.Because of this, it must check that the return value of
new(std::nothrow)is null. The cpp/incorrect-allocation-error-handling incorrectly suggests that the allocation cannot return null, despite the fact that it can. Suggesting the incorrect error handling of memory allocation is dangerous and can lead to serious bugs.It looks like cpp/incorrect-allocation-error-handling query has logic for handling std::nothrow but isn't successfully matching these calls to
new(std::nothrow).https://lgtm.com/projects/g/nasa/fprime/rev/pr-47d3627dbb3106f32896b17edc48b8829d494566