forked from 0ad/0ad
fix: shared_ptr dtor was calling delete on m_data, not delete[]
fix: freeing DirWatchRequest while IO was in-flight caused memory corruption. now CancelIO when destroying the request. This was SVN commit r7262.
This commit is contained in:
parent
47420c363b
commit
29c1f282ec
@ -22,6 +22,7 @@
|
||||
#include "precompiled.h"
|
||||
#include "lib/sysdep/dir_watch.h"
|
||||
|
||||
#include "lib/allocators/shared_ptr.h"
|
||||
#include "lib/path_util.h" // path_is_subpath
|
||||
#include "win.h"
|
||||
#include "winit.h"
|
||||
@ -75,11 +76,16 @@ class DirWatchRequest
|
||||
{
|
||||
public:
|
||||
DirWatchRequest(const fs::wpath& path)
|
||||
: m_path(path), m_dirHandle(path), m_data(new u8[dataSize])
|
||||
: m_path(path), m_dirHandle(path), m_data(new u8[dataSize], ArrayDeleter())
|
||||
{
|
||||
memset(&m_ovl, 0, sizeof(m_ovl));
|
||||
}
|
||||
|
||||
~DirWatchRequest()
|
||||
{
|
||||
WARN_IF_FALSE(CancelIo(m_dirHandle));
|
||||
}
|
||||
|
||||
const fs::wpath& Path() const
|
||||
{
|
||||
return m_path;
|
||||
@ -292,7 +298,7 @@ public:
|
||||
ovl = 0;
|
||||
const DWORD timeout = 0;
|
||||
const BOOL gotPacket = GetQueuedCompletionStatus(m_hIOCP, &dwBytesTransferred, &ulKey, &ovl, timeout);
|
||||
bytesTransferred = size_t(bytesTransferred);
|
||||
bytesTransferred = size_t(dwBytesTransferred);
|
||||
key = uintptr_t(ulKey);
|
||||
if(gotPacket)
|
||||
return INFO::OK;
|
||||
|
Loading…
Reference in New Issue
Block a user