mirror of
https://github.com/github/codeql.git
synced 2026-02-12 21:21:16 +01:00
11 lines
373 B
C++
11 lines
373 B
C++
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.
|
|
return new_buffer;
|
|
}
|