Review Request 111040: Fix possibly memory leak by not called destructor on incomplete type in kis_mask.cc
Friedrich W. H. Kossebau
kossebau at kde.org
Sat Jun 15 14:19:48 BST 2013
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://git.reviewboard.kde.org/r/111040/
-----------------------------------------------------------
Review request for Calligra, Dmitry Kazakov and Boudewijn Rempt.
Description
-------
Noone noticed this warning by the compiler?
[ 37%] Building CXX object krita/image/CMakeFiles/kritaimage.dir/kis_mask.cc.o
/home/koder/Kode/kdegit/Calligra/calligra/krita/image/kis_mask.cc: In member function ‘void KisMask::Private::initSelectionImpl(KisSelectionSP, KisLayerSP, KisPaintDeviceSP)’:
/home/koder/Kode/kdegit/Calligra/calligra/krita/image/kis_mask.cc:149:39: warning: possible problem detected in invocation of delete operator: [enabled by default]
/home/koder/Kode/kdegit/Calligra/calligra/krita/image/kis_mask.cc:149:39: warning: invalid use of incomplete type ‘class KUndo2Command’ [enabled by default]
In file included from /home/koder/Kode/kdegit/Calligra/calligra/krita/image/kis_mask.h:25:0,
from /home/koder/Kode/kdegit/Calligra/calligra/krita/image/kis_mask.cc:20:
/home/koder/Kode/kdegit/Calligra/calligra/krita/image/kis_types.h:229:7: warning: forward declaration of ‘class KUndo2Command’ [enabled by default]
/home/koder/Kode/kdegit/Calligra/calligra/krita/image/kis_mask.cc:149:39: note: neither the destructor nor the class-specific operator delete will be called, even if they are declared when the class is defined
See e.g. http://en.wikibooks.org/wiki/More_C++_Idioms/Checked_delete for the background. Short, delete on objects of incomplete type is just undefined, so not an error usually, thus the compiler will not stop on it.
Attached patch fixes it by including kundo2command.h as needed to complete the type. Don't have sufficient understanding of the surrounding code, so please check if this does result in what is wanted here.
In general:
Please watch the compiler warnings. Ideally there are NullNada????? warnings :)
Diffs
-----
krita/image/kis_mask.cc b6388a7
Diff: http://git.reviewboard.kde.org/r/111040/diff/
Testing
-------
Thanks,
Friedrich W. H. Kossebau
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/calligra-devel/attachments/20130615/4dd1d898/attachment.htm>
More information about the calligra-devel
mailing list