diff --git a/lib/gamelib/anim.cpp b/lib/gamelib/anim.cpp index d8e5ae29a..d3b0c0b6a 100644 --- a/lib/gamelib/anim.cpp +++ b/lib/gamelib/anim.cpp @@ -172,6 +172,7 @@ BOOL anim_Create3D(char szPieFileName[], UWORD uwStates, UWORD uwFrameRate, UWOR if ( ubType == ANIM_3D_TRANS && uwObj != uwFrames ) { ASSERT(false, "Frames in pie %s != script objects %i", szPieFileName, uwObj); + free(psAnim3D); return false; } diff --git a/lib/script/event.cpp b/lib/script/event.cpp index 3c29547c8..68d0d2a4a 100644 --- a/lib/script/event.cpp +++ b/lib/script/event.cpp @@ -415,6 +415,7 @@ BOOL eventNewContext(SCRIPT_CODE *psCode, CONTEXT_RELEASE release, if (!asCreateFuncs[type](&(psCode->ppsLocalVarVal[i][j]) )) { debug(LOG_ERROR,"eventNewContext: asCreateFuncs failed for local var"); + free(psContext); return false; } } diff --git a/lib/sequence/sequence.cpp b/lib/sequence/sequence.cpp index 1c0b44218..b3825f58c 100644 --- a/lib/sequence/sequence.cpp +++ b/lib/sequence/sequence.cpp @@ -671,9 +671,7 @@ bool seq_Play(const char* filename) /* open video */ if (theora_p) { - char *blackframe = (char *)calloc(1, texture_width * texture_height * 4); - if (videodata.ti.frame_width > texture_width || - videodata.ti.frame_height > texture_height) + if (videodata.ti.frame_width > texture_width || videodata.ti.frame_height > texture_height) { debug(LOG_ERROR, "Video size too large, must be below %dx%d!", texture_width, texture_height); @@ -684,6 +682,7 @@ bool seq_Play(const char* filename) debug(LOG_ERROR, "Video not in YUV420 format!"); return false; } + char *blackframe = (char *)calloc(1, texture_width * texture_height * 4); Allocate_videoFrame(); glGenTextures(1, &video_texture); diff --git a/src/main.cpp b/src/main.cpp index 0d95c55a4..50b7f36de 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -270,14 +270,13 @@ void clearOverrideMods(void) void addLoadedMod(const char * modname) { - char * mod = strdup(modname); - int i, modlen; if (num_loaded_mods >= MAX_MODS) { // mod list full return; } - modlen = strlen(mod); + char *mod = strdup(modname); + int modlen = strlen(mod); if (modlen >= 3 && strcmp(&mod[modlen-3], ".wz")==0) { // remove ".wz" from end @@ -305,7 +304,8 @@ void addLoadedMod(const char * modname) // Yes, this is an online insertion sort. // I swear, for the numbers of mods this is going to be dealing with // (i.e. 0 to 2), it really is faster than, say, Quicksort. - for (i=0; i0; i++) {} + int i; + for (i = 0; i < num_loaded_mods && strcmp(loaded_mods[i], mod) > 0; i++) {} if (i < num_loaded_mods) { if (strcmp(loaded_mods[i], mod) == 0)