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

clang-static-analyzer: Dereference of null pointer in any_executor.hpp #1572

Open
rohansuri opened this issue Dec 16, 2024 · 0 comments
Open

Comments

@rohansuri
Copy link

Hello,
Thank you for the wonderful library. I am using it for a http client. However, I see clang-analyzer report the following issue.

boost version: 1.82.0
clang-version: 9.0.0

scan-build: Using '/usr/local/bin/clang-9' for static analysis
The C compiler identification is Clang 9.0.0
The CXX compiler identification is Clang 9.0.0

File name: include/boost/asio/execution/any_executor.hpp
Line number: 1931
Code snippet:


template <typename Property>
1925 | any_executor prefer(const Property& p,
1926 | typename enable_if<
1927 | find_convertible_preferable_property<Property>::value
1928 | >::type* = 0) const
1929 | {
1930 | typedef find_convertible_preferable_property<Property> found;
1931 | return prop_fns_[found::index].prefer(object_fns_->target(*this),
1932 | &static_cast<const typename found::type&>(p));
1933 | }

Exact error reported in scan report:

Access to field 'target' results in a dereference of a null pointer (loaded from field 'object_fns_')

Warning emitted during the build itself:

In file included from include/boost/asio.hpp:20:
In file included from include/boost/asio/any_completion_executor.hpp:22:
In file included from include/boost/asio/execution.hpp:19:
include/boost/asio/execution/any_executor.hpp:1931:43: warning: Access to field 'target' results in a dereference of a null pointer (loaded from field 'object_fns_')
return prop_fns_[found::index].prefer(object_fns_->target(*this),
                                           ^~~~~~~~~~~~~~~~~~~
1 warning generated.
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

No branches or pull requests

1 participant