client: Fix filesystem memory leaks

This commit is contained in:
Denis Pauk 2024-08-28 00:45:02 +03:00
parent 04aec20891
commit a7cb9431b3
2 changed files with 28 additions and 6 deletions

View file

@ -5695,11 +5695,19 @@ HasSkinsInDir(const char *dirname, int *num)
for (j = 0; j < num_png; j ++) for (j = 0; j < num_png; j ++)
{ {
if (list_png[j] && !strchr(list_png[j] + dirname_size, '/')) if (list_png[j])
{
if (!strchr(list_png[j] + dirname_size, '/'))
{ {
*curr = list_png[j]; *curr = list_png[j];
curr++; curr++;
} }
else
{
/* unused in final response */
free(list_png[j]);
}
}
} }
free(list_png); free(list_png);
@ -5711,11 +5719,19 @@ HasSkinsInDir(const char *dirname, int *num)
for (j = 0; j < num_pcx; j ++) for (j = 0; j < num_pcx; j ++)
{ {
if (list_pcx[j] && !strchr(list_pcx[j] + dirname_size, '/')) if (list_pcx[j])
{
if (!strchr(list_pcx[j] + dirname_size, '/'))
{ {
*curr = list_pcx[j]; *curr = list_pcx[j];
curr++; curr++;
} }
else
{
/* unused in final response */
free(list_pcx[j]);
}
}
} }
free(list_pcx); free(list_pcx);

View file

@ -731,6 +731,12 @@ FS_LoadFile(const char *path, void **buffer)
if (size <= 0) if (size <= 0)
{ {
if (size == 0)
{
/* empty file, close before exit*/
FS_FCloseFile(f);
}
if (buffer) if (buffer)
{ {
*buffer = NULL; *buffer = NULL;