Merge pull request #13874 from jketema/use-after-free

C++: Improve use-after-free example code
This commit is contained in:
Jeroen Ketema
2023-08-03 13:21:12 +02:00
committed by GitHub

View File

@@ -1,9 +1,10 @@
int f() {
void f() {
char* buf = new char[SIZE];
....
...
if (error) {
free(buf); //error handling has freed the buffer
delete buf; //error handling has freed the buffer
}
...
log_contents(buf); //but it is still used here for logging
...
}