diff --git a/src/common/imagbmp.cpp b/src/common/imagbmp.cpp index 7a92ab9217..bade1bd9e2 100644 --- a/src/common/imagbmp.cpp +++ b/src/common/imagbmp.cpp @@ -33,6 +33,7 @@ #include "wx/wfstream.h" #include "wx/quantize.h" #include "wx/scopeguard.h" +#include "wx/scopedarray.h" #include "wx/anidecod.h" // For memcpy @@ -1425,8 +1426,8 @@ bool wxICOHandler::DoLoadFile(wxImage *image, wxInputStream& stream, wxUint16 nType = wxUINT16_SWAP_ON_BE(IconDir.idType); // loop round the icons and choose the best one: - ICONDIRENTRY *pIconDirEntry = new ICONDIRENTRY[nIcons]; - ICONDIRENTRY *pCurrentEntry = pIconDirEntry; + wxScopedArray pIconDirEntry(nIcons); + ICONDIRENTRY *pCurrentEntry = pIconDirEntry.get(); int wMax = 0; int colmax = 0; int iSel = wxNOT_FOUND; @@ -1473,7 +1474,7 @@ bool wxICOHandler::DoLoadFile(wxImage *image, wxInputStream& stream, else { // seek to selected icon: - pCurrentEntry = pIconDirEntry + iSel; + pCurrentEntry = pIconDirEntry.get() + iSel; // NOTE: seeking a positive amount in wxFromCurrent mode allows us to // load even non-seekable streams (see wxInputStream::SeekI docs)! @@ -1491,8 +1492,6 @@ bool wxICOHandler::DoLoadFile(wxImage *image, wxInputStream& stream, } } - delete [] pIconDirEntry; - return bResult; }