Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions cpp/include/ktbind/dummy.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#include <iostream>

void causeNullPointerError() {
int* ptr = nullptr; // 1. Pointer is explicitly set to NULL

// ... some other logic ...

// 2. ERROR: Dereferencing the null pointer
*ptr = 42;

std::cout << "Value: " << *ptr << std::endl;
}

void checkAfterDereference(int* x) {
// 3. ERROR: Dereferencing 'x' before checking if it is null
*x = 10;

if (x == nullptr) {
return;
}
}

int main() {
causeNullPointerError();

int* val = nullptr;
checkAfterDereference(val);

return 0;
}