Fix some memory errors (bug 5904, r=ds).
This commit is contained in:
parent
66dd3f08b1
commit
96d6cf8def
@ -212,7 +212,7 @@ void CHalfLife2::InitCommandLine()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ILibrary *lib = g_LibSys.OpenLibrary(path, error, sizeof(error));
|
ke::AutoPtr<ILibrary> lib(g_LibSys.OpenLibrary(path, error, sizeof(error)));
|
||||||
m_pGetCommandLine = lib->GetSymbolAddress("CommandLine_Tier0");
|
m_pGetCommandLine = lib->GetSymbolAddress("CommandLine_Tier0");
|
||||||
|
|
||||||
/* '_Tier0' dropped on Alien Swarm version */
|
/* '_Tier0' dropped on Alien Swarm version */
|
||||||
@ -224,7 +224,6 @@ void CHalfLife2::InitCommandLine()
|
|||||||
if (m_pGetCommandLine == NULL)
|
if (m_pGetCommandLine == NULL)
|
||||||
{
|
{
|
||||||
/* We probably have a Ship engine. */
|
/* We probably have a Ship engine. */
|
||||||
lib->CloseLibrary();
|
|
||||||
g_SourceMod.BuildPath(Path_Game, path, sizeof(path), "../bin/" VSTDLIB_NAME);
|
g_SourceMod.BuildPath(Path_Game, path, sizeof(path), "../bin/" VSTDLIB_NAME);
|
||||||
if (!g_LibSys.IsPathFile(path))
|
if (!g_LibSys.IsPathFile(path))
|
||||||
{
|
{
|
||||||
@ -244,8 +243,6 @@ void CHalfLife2::InitCommandLine()
|
|||||||
{
|
{
|
||||||
g_Logger.LogError("Could not locate any command line functionality");
|
g_Logger.LogError("Could not locate any command line functionality");
|
||||||
}
|
}
|
||||||
|
|
||||||
lib->CloseLibrary();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#include <ISourceMod.h>
|
#include <ISourceMod.h>
|
||||||
#include "common_logic.h"
|
#include "common_logic.h"
|
||||||
#include "PluginSys.h"
|
#include "PluginSys.h"
|
||||||
|
#include <am-utility.h>
|
||||||
|
|
||||||
CExtensionManager g_Extensions;
|
CExtensionManager g_Extensions;
|
||||||
IdentityType_t g_ExtType;
|
IdentityType_t g_ExtType;
|
||||||
@ -537,11 +538,9 @@ void CExtensionManager::TryAutoload()
|
|||||||
|
|
||||||
g_pSM->BuildPath(Path_SM, path, sizeof(path), "extensions");
|
g_pSM->BuildPath(Path_SM, path, sizeof(path), "extensions");
|
||||||
|
|
||||||
IDirectory *pDir = libsys->OpenDirectory(path);
|
ke::AutoPtr<IDirectory> pDir(libsys->OpenDirectory(path));
|
||||||
if (!pDir)
|
if (!pDir)
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
const char *lfile;
|
const char *lfile;
|
||||||
size_t len;
|
size_t len;
|
||||||
|
@ -186,6 +186,7 @@ static bool get_game_name(char *buffer, size_t maxlength)
|
|||||||
if ((str = pGameInfo->GetString("game", NULL)) != NULL)
|
if ((str = pGameInfo->GetString("game", NULL)) != NULL)
|
||||||
{
|
{
|
||||||
strncopy(buffer, str, maxlength);
|
strncopy(buffer, str, maxlength);
|
||||||
|
pGameInfo->deleteThis();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,7 +84,7 @@ TopMenu::~TopMenu()
|
|||||||
{
|
{
|
||||||
TearDownClient(&m_clients[i]);
|
TearDownClient(&m_clients[i]);
|
||||||
}
|
}
|
||||||
delete [] m_clients;
|
free(m_clients);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int TopMenu::CalcMemUsage()
|
unsigned int TopMenu::CalcMemUsage()
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
# include <intrin.h>
|
# include <intrin.h>
|
||||||
#endif
|
#endif
|
||||||
|
#include <am-moveable.h>
|
||||||
|
|
||||||
#define KE_32BIT
|
#define KE_32BIT
|
||||||
|
|
||||||
@ -62,6 +63,18 @@ ReturnAndVoid(T &t)
|
|||||||
return saved;
|
return saved;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if __cplusplus >= 201103L
|
||||||
|
# define KE_CXX11
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(KE_CXX11)
|
||||||
|
# define KE_DELETE = delete
|
||||||
|
# define KE_OVERRIDE = override
|
||||||
|
#else
|
||||||
|
# define KE_DELETE
|
||||||
|
# define KE_OVERRIDE
|
||||||
|
#endif
|
||||||
|
|
||||||
// Wrapper that automatically deletes its contents. The pointer can be taken
|
// Wrapper that automatically deletes its contents. The pointer can be taken
|
||||||
// to avoid destruction.
|
// to avoid destruction.
|
||||||
template <typename T>
|
template <typename T>
|
||||||
@ -74,10 +87,15 @@ class AutoPtr
|
|||||||
: t_(NULL)
|
: t_(NULL)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
explicit AutoPtr(T *t)
|
AutoPtr(T *t)
|
||||||
: t_(t)
|
: t_(t)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
AutoPtr(Moveable<AutoPtr<T> > &other)
|
||||||
|
{
|
||||||
|
t_ = other->t_;
|
||||||
|
other->t_ = NULL;
|
||||||
|
}
|
||||||
~AutoPtr() {
|
~AutoPtr() {
|
||||||
delete t_;
|
delete t_;
|
||||||
}
|
}
|
||||||
@ -93,13 +111,24 @@ class AutoPtr
|
|||||||
operator T *() const {
|
operator T *() const {
|
||||||
return t_;
|
return t_;
|
||||||
}
|
}
|
||||||
void operator =(T *t) {
|
T *operator =(T *t) {
|
||||||
delete t_;
|
delete t_;
|
||||||
t_ = t;
|
t_ = t;
|
||||||
|
return t_;
|
||||||
|
}
|
||||||
|
T *operator =(Moveable<AutoPtr<T> > &other) {
|
||||||
|
delete t_;
|
||||||
|
t_ = other->t_;
|
||||||
|
other->t_ = NULL;
|
||||||
|
return t_;
|
||||||
}
|
}
|
||||||
bool operator !() const {
|
bool operator !() const {
|
||||||
return !t_;
|
return !t_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
AutoPtr(const AutoPtr &other) KE_DELETE;
|
||||||
|
AutoPtr &operator =(const AutoPtr &other) KE_DELETE;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Wrapper that automatically deletes its contents. The pointer can be taken
|
// Wrapper that automatically deletes its contents. The pointer can be taken
|
||||||
@ -298,18 +327,6 @@ class StorageBuffer
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
#if __cplusplus >= 201103L
|
|
||||||
# define KE_CXX11
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(KE_CXX11)
|
|
||||||
# define KE_DELETE delete
|
|
||||||
# define KE_OVERRIDE override
|
|
||||||
#else
|
|
||||||
# define KE_DELETE
|
|
||||||
# define KE_OVERRIDE
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
# define KE_SIZET_FMT "%Iu"
|
# define KE_SIZET_FMT "%Iu"
|
||||||
#elif defined(__GNUC__)
|
#elif defined(__GNUC__)
|
||||||
|
@ -256,7 +256,7 @@ Interpret(BaseRuntime *rt, uint32_t aCodeStart, cell_t *rval)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case OP_ZERO_S:
|
case OP_ZERO_S:
|
||||||
Write(plugin, *cip++, 0);
|
Write(plugin, ctx->frm + *cip++, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case OP_PUSH_PRI:
|
case OP_PUSH_PRI:
|
||||||
|
Loading…
Reference in New Issue
Block a user