The following code triggers a "Null pointer dereference" error:
#include <sqlite3.h> #include <stddef.h> void f(const char* filename, int flags) { sqlite3* handle; sqlite3_open_v2(filename, &handle, flags, NULL); sqlite3_close_v2(handle); }
cppcheck 2.15.0 outputs:
$ cppcheck --library=sqlite3 ./test.c Checking test.c ... test.c:6:47: error: Null pointer dereference [nullPointer] sqlite3_open_v2(filename, &handle, flags, NULL);
Looking at the SQLite documentation, using NULL (or nullptr in C++) is allowed and has a special meaning:
If the fourth parameter is a NULL pointer then the default sqlite3_vfs object is used.
This probably originates from commit 76f1aac which first appeared in v2.15.0.
Have you considered opening a PR at https://github.com/danmar/cppcheck?
https://trac.cppcheck.net/ticket/13078
Log in to post a comment.
The following code triggers a "Null pointer dereference" error:
cppcheck 2.15.0 outputs:
Looking at the SQLite documentation, using NULL (or nullptr in C++) is allowed and has a special meaning:
This probably originates from commit 76f1aac which first appeared in v2.15.0.
Have you considered opening a PR at https://github.com/danmar/cppcheck?
https://trac.cppcheck.net/ticket/13078