mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-03-25 08:40:30 +01:00
Fix memory leaks
This commit is contained in:
parent
2d5d9287c6
commit
2d4c195c86
@ -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
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user