Im trying to push back a pointer of a newly created object into a vector but for some reason I get a access violation with something related to scalar delete operator
Here is where the crash happens:
Exception thrown at 0x0F9366CB (ucrtbased.dll) in Battleship.exe: 0xC0000005: Access violation reading location 0xCDCDCDBD.
The file where the crash happens:
//
// delete_scalar.cpp
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// Defines the scalar operator delete.
//
#include <crtdbg.h>
#include <malloc.h>
#include <vcruntime_new.h>
void __CRTDECL operator delete(void* const block) noexcept
{
#ifdef _DEBUG
_free_dbg(block, _UNKNOWN_BLOCK); // *****Crashes here*****
#else
free(block);
#endif
}
This is how I allocate memory:
NetSocket* newSocket_ptr = new NetSocket();
m_sockets.emplace_back(newSocket_ptr);