Prevent some heap corruptions/exceptions

This commit is contained in:
twinaphex 2018-01-23 03:41:25 +01:00
parent 93561a042b
commit 6a47669d21
4 changed files with 7 additions and 4 deletions

View File

@ -22,7 +22,8 @@ FILE* fopen_utf8(const char * filename, const char * mode)
if (!filename_local)
return NULL;
ret = fopen(filename_local, mode);
free(filename_local);
if (filename_local)
free(filename_local);
return ret;
#else
wchar_t * filename_w = utf8_to_utf16_string_alloc(filename);

View File

@ -1220,7 +1220,7 @@ bool rpng_set_buf_ptr(rpng_t *rpng, void *data)
rpng_t *rpng_alloc(void)
{
rpng_t *rpng = (rpng_t*)calloc(1, sizeof(rpng_t));
rpng_t *rpng = (rpng_t*)calloc(1, sizeof(*rpng));
if (!rpng)
return NULL;
return rpng;

View File

@ -69,7 +69,8 @@ static void zlib_inflate_stream_free(void *data)
return;
if (z->inited)
inflateEnd(&z->z);
free(z);
if (z)
free(z);
}
static bool zlib_deflate_define(void *data, const char *prop, uint32_t val)

View File

@ -3893,7 +3893,8 @@ static void xmb_context_reset(void *data, bool is_threaded)
xmb_update_thumbnail_image(xmb);
xmb_update_savestate_thumbnail_image(xmb);
free(iconpath);
if (iconpath)
free(iconpath);
}
}