SLUDGE: fix unmatched delete[] leaks

This commit is contained in:
yinsimei 2017-06-06 01:59:44 +02:00 committed by Eugene Sandulenko
parent 77d5c7235d
commit 839e7fb4d2
8 changed files with 18 additions and 18 deletions

View file

@ -180,7 +180,7 @@ static builtReturn sayCore(int numParams, loadedFunction *fun, bool sayIt) {
fun->timeLeft = p;
//debugOut ("BUILTIN: sayCore: %s (%i)\n", newText, p);
fun->isSpeech = true;
delete newText;
delete[] newText;
newText = NULL;
return BR_KEEP_AND_PAUSE;
}
@ -887,7 +887,7 @@ builtIn(setFont) {
if (!loadFont(fileNumber, newText, newHeight))
return BR_ERROR;
// newDebug (" Done!");
delete newText;
delete[] newText;
return BR_CONTINUE;
}
@ -1862,7 +1862,7 @@ builtIn(statusText) {
return BR_ERROR;
trimStack(fun->stack);
setStatusBar(newText);
delete newText;
delete[] newText;
return BR_CONTINUE;
}

View file

@ -231,10 +231,10 @@ bool setFloor(int fileNum) {
} while (madeChange);
for (i = 0; i < currentFloor->numPolygons; i++) {
delete distanceMatrix[i];
delete[] distanceMatrix[i];
}
delete distanceMatrix;
delete []distanceMatrix;
distanceMatrix = NULL;
setResourceForFatal(-1);

View file

@ -76,7 +76,7 @@ char *getPrefsFilename(char *filename) {
char *joined = joinStrings(f, ".ini");
delete filename;
delete[] filename;
filename = NULL;
return joined;
}

View file

@ -81,7 +81,7 @@ void warning(const char *l) {
}
void registerWindowForFatal() {
delete fatalInfo;
delete[] fatalInfo;
fatalInfo =
joinStrings("There's an error with this SLUDGE game! If you're designing this game, please turn on verbose error messages in the project manager and recompile. If not, please contact the author saying where and how this problem occured.", "");
}
@ -126,7 +126,7 @@ int checkNew(const void *mem) {
}
void setFatalInfo(const char *userFunc, const char *BIF) {
delete fatalInfo;
delete[] fatalInfo;
fatalInfo = new char[strlen(userFunc) + strlen(BIF) + 38];
if (fatalInfo)
sprintf(fatalInfo, "Currently in this sub: %s\nCalling: %s", userFunc, BIF);

View file

@ -266,7 +266,7 @@ bool initSludge(const char *filename) {
if (strcmp(checker, "okSoFar"))
return fatal(ERROR_BAD_HEADER, filename);
delete checker;
delete[] checker;
checker = NULL;
unsigned char customIconLogo = fp->readByte();
@ -509,7 +509,7 @@ bool initSludge(const char *filename) {
char *gameName = encodeFilename(gameNameOrig);
delete gameNameOrig;
delete[] gameNameOrig;
#if 0
changeToUserDir();
@ -767,10 +767,10 @@ void finishFunction(loadedFunction *fun) {
pauseFunction(fun);
if (fun->stack)
fatal(ERROR_NON_EMPTY_STACK);
delete fun->compiledLines;
delete[] fun->compiledLines;
for (a = 0; a < fun->numLocals; a++)
unlinkVar(fun->localVars[a]);
delete fun->localVars;
delete[] fun->localVars;
unlinkVar(fun->reg);
delete fun;
fun = NULL;
@ -785,7 +785,7 @@ void abortFunction(loadedFunction *fun) {
delete fun->compiledLines;
for (a = 0; a < fun->numLocals; a++)
unlinkVar(fun->localVars[a]);
delete fun->localVars;
delete[] fun->localVars;
unlinkVar(fun->reg);
if (fun->calledBy)
abortFunction(fun->calledBy);

View file

@ -78,7 +78,7 @@ void addStatusBar() {
void setStatusBar(char *txt) {
if (nowStatus->firstStatusBar) {
delete nowStatus->firstStatusBar->text;
delete[] nowStatus->firstStatusBar->text;
nowStatus->firstStatusBar->text = copyString(txt);
}
}

View file

@ -70,7 +70,7 @@ void killAllSpeech() {
while (speech->allSpeech) {
killMe = speech->allSpeech;
speech->allSpeech = speech->allSpeech->next;
delete killMe->textLine;
delete[] killMe->textLine;
delete killMe;
}
}

View file

@ -336,14 +336,14 @@ char *getTextFromAnyVar(const variable &from) {
builder2 = joinStrings(builder, " ");
if (!builder2)
return NULL;
delete builder;
delete[] builder;
grabText = getTextFromAnyVar(stacky->thisVar);
builder = joinStrings(builder2, grabText);
if (!builder)
return NULL;
delete grabText;
delete[] grabText;
grabText = NULL;
delete builder2;
delete[] builder2;
builder2 = NULL;
stacky = stacky->next;
}