Skip to content

Commit 48048d6

Browse files
authored
Merge pull request #13874 from jketema/use-after-free
C++: Improve use-after-free example code
2 parents 00c7042 + 0c0720a commit 48048d6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

cpp/ql/src/Critical/UseAfterFree.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
int f() {
1+
void f() {
22
char* buf = new char[SIZE];
3-
....
3+
...
44
if (error) {
5-
free(buf); //error handling has freed the buffer
5+
delete buf; //error handling has freed the buffer
66
}
77
...
88
log_contents(buf); //but it is still used here for logging
9+
...
910
}

0 commit comments

Comments
 (0)