Skip to content

[BUG]: Coverity issue in dispatcher: Possible dereferencing null pointer self_value_and_holder.type #4821

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

Open
3 tasks done
oleksandr-pavlyk opened this issue Aug 27, 2023 · 1 comment
Labels
triage New bug, unverified

Comments

@oleksandr-pavlyk
Copy link
Contributor

Required prerequisites

What version (or hash if on master) of pybind11 are you using?

2.10.2

Problem description

Coverity scan highlights possible explicit null pointer dereferencing in pybind11 dispatcher function in "pybind11.h".

The tools indicates that self_value_and_holder variable is initialized with default-constructed value_and_holder class which sets type pointer to NULL:

image

It stays NULL if overloads->is_constructor condition is false.

The type field is dereferenced here:

image

This maybe a false positive, since func.is_new_style_constructor might imply overloads->is_constructor, `but I could not determine that conclusively, hence this issue.

Reproducible example code

No response

Is this a regression? Put the last known working version here if it is.

Not a regression

@oleksandr-pavlyk oleksandr-pavlyk added the triage New bug, unverified label Aug 27, 2023
@oleksandr-pavlyk oleksandr-pavlyk changed the title [BUG]: [BUG]: Coverity issue in dispatcher Aug 27, 2023
@oleksandr-pavlyk oleksandr-pavlyk changed the title [BUG]: Coverity issue in dispatcher [BUG]: Coverity issue in dispatcher: Possible dereferencing null pointer self_value_and_holder.type Aug 27, 2023
@rwgk
Copy link
Collaborator

rwgk commented Sep 25, 2023

This one I'd also silence via assert() and -UNDEBUG.

assert(self_value_and_holder.type != nullptr);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage New bug, unverified
Projects
None yet
Development

No branches or pull requests

2 participants