mirror of
https://github.com/github/codeql.git
synced 2025-12-18 01:33:15 +01:00
C++: Improve the example for cpp/return-stack-allocated-memory.
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
Record* fixRecord(Record* r) {
|
||||
Record myRecord = *r;
|
||||
delete r;
|
||||
Record *mkRecord(int value) {
|
||||
Record myRecord(value);
|
||||
|
||||
myRecord.fix();
|
||||
return &myRecord; //returns reference to myRecord, which is a stack-allocated object
|
||||
}
|
||||
return &myRecord; // BAD: return a pointer to `myRecord`, which is a stack-allocated object
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user