Skip to content

Commit

Permalink
Fix memory leaks
Browse files Browse the repository at this point in the history
  • Loading branch information
CapacitorSet authored and jacob1 committed Mar 20, 2017
1 parent 2d5d928 commit 2d4c195
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/Platform.cpp
@@ -1,6 +1,7 @@
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cassert>
#ifdef WIN
#include <shlobj.h>
#include <shlwapi.h>
Expand Down Expand Up @@ -31,7 +32,9 @@ char *ExecutableName(void)
uint32_t max = 64, res;
if (_NSGetExecutablePath(fn, &max) != 0)
{
fn = (char*)realloc(fn, max);
char *realloced_fn = (char*)realloc(fn, max);
assert(realloced_fn != NULL);
fn = realloced_fn;
_NSGetExecutablePath(fn, &max);
}
if (realpath(fn, name) == NULL)
Expand All @@ -51,7 +54,9 @@ char *ExecutableName(void)
#endif
#ifndef MACOSX
max *= 2;
name = (char *)realloc(name, max);
char* realloced_name = (char *)realloc(name, max);
assert(realloced_name != NULL);
name = realloced_name;
memset(name, 0, max);
}
#endif
Expand Down
4 changes: 3 additions & 1 deletion src/simulation/Simulation.cpp
Expand Up @@ -1010,8 +1010,10 @@ void Simulation::ApplyDecorationFill(Renderer *ren, int x, int y, int colR, int
return;
memset(bitmap, 0, XRES*YRES);

if (!ColorCompare(ren, x, y, replaceR, replaceG, replaceB))
if (!ColorCompare(ren, x, y, replaceR, replaceG, replaceB)) {
free(bitmap);
return;
}

try
{
Expand Down

0 comments on commit 2d4c195

Please sign in to comment.