Permalink
Browse files

Fix memory leaks

  • Loading branch information...
CapacitorSet authored and jacob1 committed Nov 14, 2016
1 parent 2d5d928 commit 2d4c195c8671be815db8628a59c38a8fbbd97f33
Showing with 10 additions and 3 deletions.
  1. +7 −2 src/Platform.cpp
  2. +3 −1 src/simulation/Simulation.cpp
@@ -1,6 +1,7 @@
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cassert>
#ifdef WIN
#include <shlobj.h>
#include <shlwapi.h>
@@ -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)
@@ -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
@@ -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
{

0 comments on commit 2d4c195

Please sign in to comment.