Compare commits

...

6 Commits

Author SHA1 Message Date
Sam Robson
d6acdb32f2 Merge branch 'main' into oscarsj/test-cpp-internal-checks 2025-04-14 15:31:52 +01:00
Sam Robson
b65858fbcf trigger checks 2025-04-14 15:21:20 +01:00
Sam Robson
60e250c3ae trigger checks 2025-04-14 15:01:46 +01:00
Óscar San José
bdda2a7773 Fix indentation in DoubleFreeBad.cpp comments 2025-04-14 14:44:59 +02:00
Óscar San José
fb3140a6cd Add missing newline in DoubleFreeBad.cpp 2025-04-14 14:42:33 +02:00
Óscar San José
f57b1d3186 force dummy change to trigger internal checks 2024-05-17 16:24:20 +02:00

View File

@@ -1,10 +1,13 @@
int* f() {
int *buff = malloc(SIZE*sizeof(int));
do_stuff(buff);
free(buff);
int *new_buffer = malloc(SIZE*sizeof(int));
free(buff); // BAD: If new_buffer is assigned the same address as buff,
// the memory allocator will free the new buffer memory region,
// leading to use-after-free problems and memory corruption.
free(buff);
// BAD: If new_buffer is assigned the same address as buff,
// the memory allocator will free the new buffer memory region,
// leading to use-after-free problems and memory corruption.
// abc
return new_buffer;
}