Skip to content

[Coverity CID: 220413] Explicit null dereferenced in tests/lib/sprintf/src/main.c #33822

@zephyrbot

Description

@zephyrbot

Static code scan issues found in file:

https://github.com/zephyrproject-rtos/zephyr/tree/169144afa1826511ee6ec3f53d590b2c0d39d3d4/tests/lib/sprintf/src/main.c#L748

Category: Null pointer dereferences
Function: test_print
Component: Tests
CID: 220413

Details:

ret = fprintf(p, "%d", i);

742         int ret, i = 3;
743         FILE *p = NULL;
744    
745         ret = fprintf(stdout,  "%d", i);
746         zassert_equal(ret, 1, "fprintf failed!");
747    
>>>     CID 220413:  Null pointer dereferences  (FORWARD_NULL)
>>>     Passing null pointer "p" to "fprintf", which dereferences it. [Note: The source code implementation of the function has been overridden by a builtin model.]
748         ret = fprintf(p,  "%d", i);
749         zassert_not_equal(ret, 1, "fprintf failed!");
750    
751         ret = fprintf(stdout,  "", i);
752         zassert_not_equal(ret, 1, "fprintf failed!");
753    
22 new defect(s) introduced to Zephyr found with Coverity Scan.
21 defect(s), reported by Coverity Scan earlier, were marked fixed in the recent build analyzed by Coverity Scan.

Please fix or provide comments in coverity using the link:

https://scan9.coverity.com/reports.htm#v29271/p12996

Note: This issue was created automatically. Priority was set based on classification
of the file affected and the impact field in coverity. Assignees were set using the CODEOWNERS file.

Metadata

Metadata

Assignees

Labels

CoverityA Coverity detected issue or its fixbugThe issue is a bug, or the PR is fixing a bugpriority: lowLow impact/importance bug

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions