Avoid deleting object of different size than what was allocated

This commit is contained in:
Paul Cornett
2017-10-01 09:02:11 -07:00
parent 591da5dcc4
commit 29e1f1e9ce

View File

@@ -432,7 +432,7 @@ protected:
if ( it2 == m_cookies.end() ) if ( it2 == m_cookies.end() )
{ {
int size = sizeof(inevt) + inevt.len; int size = sizeof(inevt) + inevt.len;
inotify_event* e = (inotify_event*) operator new (size); inotify_event* e = (inotify_event*)new char[size];
memcpy(e, &inevt, size); memcpy(e, &inevt, size);
wxInotifyCookies::value_type val(e->cookie, e); wxInotifyCookies::value_type val(e->cookie, e);
@@ -481,7 +481,7 @@ protected:
} }
m_cookies.erase(it2); m_cookies.erase(it2);
delete &oldinevt; delete[] (char*)&oldinevt;
} }
} }
// every other kind of event // every other kind of event