Skip to main content
๐Ÿ› Bug HuntC+ C++ Mediumโšก+20 XP

Raw Pointer Memory Leak

This code leaks memory.

๐Ÿ› Find the bug
1void createObj() {
2 MyClass* obj = new MyClass();
3 obj->doWork();
4} // obj destroyed without delete
๐Ÿ› The bug is on line 4

๐Ÿ”ง Select the correct fix: