Skip to content

[Coverity CID :197605]Null pointer dereferences in /subsys/testsuite/ztest/src/ztest_mock.c #15399

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

Closed
aasthagr opened this issue Apr 12, 2019 · 2 comments
Labels
area: Other bug The issue is a bug, or the PR is fixing a bug Coverity A Coverity detected issue or its fix

Comments

@aasthagr
Copy link
Collaborator

Static code scan issues seen in File: /subsys/testsuite/ztest/src/ztest_mock.c
Category: Null pointer dereferences
Function: z_ztest_check_expected_value
Component: Other
CID: 197605
Please fix or provide comments to square it off in coverity in the link: https://scan9.coverity.com/reports.htm#v32951/p12996

@aasthagr aasthagr added area: Other bug The issue is a bug, or the PR is fixing a bug Coverity A Coverity detected issue or its fix labels Apr 12, 2019
@aasthagr
Copy link
Collaborator Author

*** CID 197605: Null pointer dereferences (FORWARD_NULL)
/subsys/testsuite/ztest/src/ztest_mock.c: 196 in z_ztest_check_expected_value()
190 param = find_and_delete_value(&parameter_list, fn, name);
191 if (!param) {
192 PRINT("Failed to find parameter %s for %s\n", name, fn);
193 ztest_test_fail();
194 }
195

CID 197605:  Null pointer dereferences  (FORWARD_NULL)
Dereferencing null pointer "param".

196 expected = param->value;
197 free_parameter(param);
198
199 if (expected != val) {
200 /* We need to cast these values since the toolchain doesn't
201 * provide inttypes.h

@aescolar
Copy link
Member

False positive. Confirmed by @mtpr-ot ("the ztest_test_fail() will abort the process if param == NULL, so no NULL pointer dereference is possible."). Flagged as false positive.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Other bug The issue is a bug, or the PR is fixing a bug Coverity A Coverity detected issue or its fix
Projects
None yet
Development

No branches or pull requests

2 participants