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
10 changes: 10 additions & 0 deletions src/simple_examples/explore_me.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,18 @@

static long insecureEncrypt(long input);
static void trigger_global_buffer_overflow(const std::string &c);
// Ensure proper memory management and avoid accessing freed memory.
static void trigger_use_after_free();

// Implementation of the function should ensure no use-after-free occurs.
void trigger_use_after_free() {
// Example safe implementation:
int* ptr = new int(42); // Allocate memory
delete ptr; // Free memory
ptr = nullptr; // Avoid dangling pointer
// Do not access ptr after this point
}

void ExploreSimpleChecks(int a, int b, std::string c) {
if (a >= 20000) {
if (b >= 2000000) {
Expand Down