From a6725d9e37f128a4e4127f6a5032d928d3e9b2ce Mon Sep 17 00:00:00 2001 From: Stef Walter Date: Wed, 7 Apr 2004 22:02:34 +0000 Subject: Fixed memory leaks --- common/compat.c | 9 +++++---- common/compat.h | 4 ++++ common/usuals.h | 1 - lib/execute.c | 3 +++ 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/common/compat.c b/common/compat.c index ff8d527..e1bddef 100644 --- a/common/compat.c +++ b/common/compat.c @@ -443,13 +443,14 @@ char* strlwr(char *string) #ifndef HAVE_REALLOCF +#undef reallocf -void* reallocf(void* ptr, size_t size) +void* reallocf(void* pt, size_t sz) { - void* ret = realloc(ptr, size); + void* ret = realloc(pt, sz); - if(!ret && size) - free(ptr); + if(!ret && sz) + free(pt); return ret; } diff --git a/common/compat.h b/common/compat.h index 2d16cc4..86a9e04 100644 --- a/common/compat.h +++ b/common/compat.h @@ -29,6 +29,10 @@ #endif #endif +#ifdef WITH_DMALLOC +#include "dmalloc.h" +#endif + #ifndef HAVE_STDARG_H #error ERROR: Must have a working header #else diff --git a/common/usuals.h b/common/usuals.h index e263e74..d09fd72 100644 --- a/common/usuals.h +++ b/common/usuals.h @@ -57,5 +57,4 @@ #endif - #endif //__USUALS_H__20000613 diff --git a/lib/execute.c b/lib/execute.c index 195d783..0662849 100644 --- a/lib/execute.c +++ b/lib/execute.c @@ -1706,6 +1706,9 @@ cleanup: if(vmStack) free(vmStack); + if(text) + free(text); + while(stackVars) { memory* prev = stackVars->prev; -- cgit v1.2.3