We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3c70583 commit d52210dCopy full SHA for d52210d
cpp/ql/src/Likely Bugs/Memory Management/ReturnStackAllocatedMemory.cpp
@@ -1,7 +1,5 @@
1
-Record* fixRecord(Record* r) {
2
- Record myRecord = *r;
3
- delete r;
+Record *mkRecord(int value) {
+ Record myRecord(value);
4
5
- myRecord.fix();
6
- return &myRecord; //returns reference to myRecord, which is a stack-allocated object
7
-}
+ return &myRecord; // BAD: return a pointer to `myRecord`, which is a stack-allocated object
+}
0 commit comments