Patch #1522 2006-09-22 19:41
sethjackson
Possible free of a non-allocated object- Download
- 1522-Possible_free.patch (543 bytes)
- Category
- Application::Refinement
- Status
- Rejected
- Close date
- 2006-09-23 11:01
- Assigned to
Index: src/sdk/printing_types.cpp
===================================================================
--- src/sdk/printing_types.cpp (revision 2989)
+++ src/sdk/printing_types.cpp (working copy)
@@ -26,9 +26,15 @@
void DeInitPrinting()
{
- delete g_pageSetupData;
- g_pageSetupData = 0;
+ if (g_pageSetupData)
+ {
+ delete g_pageSetupData;
+ g_pageSetupData = 0;
+ }
- delete g_printData;
- g_printData = 0;
+ if (g_printData)
+ {
+ delete g_printData;
+ g_printData = 0;
+ }
}
History
sethjackson 2006-09-22 19:43
Just imagine calling DeInitPrinting() without first calling InitPrinting(). BTW I believe this acually happens. Check out the MainFrame dtor.
thomasdenk 2006-09-23 11:01
Just imagine this really works! :)
Seriously, this is 100% correct code. Deleting a null pointer is perfectly legal (as by the C++ standard).
Checking for null-ness before deleting a pointer is not strictly wrong, but it is unnecessary.
Thus the original code is "correct" and the patch is "wrong", sorry.