drmemory icon indicating copy to clipboard operation
drmemory copied to clipboard

Fix memory leak in test example

Open bangarumahesh22 opened this issue 2 months ago • 3 comments

This PR fixes a memory leak in the test.c example. Previously, an array allocated with malloc was not freed, causing 20 bytes of memory to remain allocated when the program exited.

Changes made:

Freed the allocated memory (ptr) before program exit to prevent the leak.

Verified using Dr. Memory that no memory leaks remain.

Verification:

Run ../build/bin/drmemory -- ./test to confirm no leaks reported.

Test compiled and ran successfully with gcc -g test.c -o test.

Impact:

This ensures proper memory management in the example code and prevents unnecessary memory leaks for users running the example.

bangarumahesh22 avatar Oct 16 '25 20:10 bangarumahesh22

Hi @maintainers 👋

I’ve submitted this small fix for a memory leak in the test example. The change frees the previously unfreed memory and has been verified using Dr. Memory.

Just checking in — please let me know if any updates or adjustments are needed. Thank you for reviewing!

bangarumahesh22 avatar Oct 23 '25 07:10 bangarumahesh22

Hi @maintainers 👋

I’ve submitted this small fix for a memory leak in the test example. The change frees the previously unfreed memory and has been verified using Dr. Memory.

Just checking in — please let me know if any updates or adjustments are needed. Thank you for reviewing!

Please see my question at https://github.com/DynamoRIO/drmemory/pull/2567#discussion_r2453878831

derekbruening avatar Oct 23 '25 15:10 derekbruening

Looks like AI slop (see https://www.theregister.com/2024/12/10/ai_slop_bug_reports/ for example)

prasun3 avatar Nov 10 '25 06:11 prasun3