fix some bugs found through Clang Static Analyzer:

- task_content.c, load_content_from_compressed_archive: fix use after free
 - platform_win32/uwp: fix frontend_..._get_powerstate never returning FRONTEND_POWERSTATE_NONE
 - platform_win32/uwp: fix whitespace
 - cheevos.c: fix potential use after free in a loop, just to be save
This commit is contained in:
LazyBumHorse 2019-07-04 21:08:01 +02:00
parent 3cbb495bd2
commit f5497a4249
5 changed files with 91 additions and 85 deletions

View File

@ -1771,7 +1771,10 @@ found:
coro->json, coro->k)) coro->json, coro->k))
CHEEVOS_ERR(RCHEEVOS_TAG "error writing badge %s\n", coro->badge_fullpath); CHEEVOS_ERR(RCHEEVOS_TAG "error writing badge %s\n", coro->badge_fullpath);
else else
{
CHEEVOS_FREE(coro->json); CHEEVOS_FREE(coro->json);
coro->json = NULL;
}
} }
} }
} }

View File

@ -218,7 +218,7 @@ enum frontend_powerstate frontend_uwp_get_powerstate(
if (status.BatteryFlag == 0xFF) if (status.BatteryFlag == 0xFF)
ret = FRONTEND_POWERSTATE_NONE; ret = FRONTEND_POWERSTATE_NONE;
if (status.BatteryFlag & (1 << 7)) else if (status.BatteryFlag & (1 << 7))
ret = FRONTEND_POWERSTATE_NO_SOURCE; ret = FRONTEND_POWERSTATE_NO_SOURCE;
else if (status.BatteryFlag & (1 << 3)) else if (status.BatteryFlag & (1 << 3))
ret = FRONTEND_POWERSTATE_CHARGING; ret = FRONTEND_POWERSTATE_CHARGING;
@ -234,6 +234,7 @@ enum frontend_powerstate frontend_uwp_get_powerstate(
if (*percent == 255) if (*percent == 255)
*percent = 0; *percent = 0;
#endif #endif
return ret; return ret;
} }

View File

@ -347,7 +347,7 @@ enum frontend_powerstate frontend_win32_get_powerstate(int *seconds, int *percen
if (status.BatteryFlag == 0xFF) if (status.BatteryFlag == 0xFF)
ret = FRONTEND_POWERSTATE_NONE; ret = FRONTEND_POWERSTATE_NONE;
if (status.BatteryFlag & (1 << 7)) else if (status.BatteryFlag & (1 << 7))
ret = FRONTEND_POWERSTATE_NO_SOURCE; ret = FRONTEND_POWERSTATE_NO_SOURCE;
else if (status.BatteryFlag & (1 << 3)) else if (status.BatteryFlag & (1 << 3))
ret = FRONTEND_POWERSTATE_CHARGING; ret = FRONTEND_POWERSTATE_CHARGING;
@ -363,6 +363,7 @@ enum frontend_powerstate frontend_win32_get_powerstate(int *seconds, int *percen
if (*percent == 255) if (*percent == 255)
*percent = 0; *percent = 0;
#endif #endif
return ret; return ret;
} }

View File

@ -557,8 +557,6 @@ static uintptr_t gdi_load_texture(void *video_data, void *data,
void *tmpdata = NULL; void *tmpdata = NULL;
gdi_texture_t *texture = NULL; gdi_texture_t *texture = NULL;
struct texture_image *image = (struct texture_image*)data; struct texture_image *image = (struct texture_image*)data;
int size = image->width *
image->height * sizeof(uint32_t);
if (!image || image->width > 2048 || image->height > 2048) if (!image || image->width > 2048 || image->height > 2048)
return 0; return 0;

View File

@ -453,12 +453,15 @@ static bool load_content_from_compressed_archive(
info[i].path = info[i].path =
additional_path_allocs->elems[additional_path_allocs->size - 1].data; additional_path_allocs->elems[additional_path_allocs->size - 1].data;
free(new_path);
if (!string_list_append(content_ctx->temporary_content, if (!string_list_append(content_ctx->temporary_content,
new_path, attributes)) new_path, attributes))
{
free(new_path);
return false; return false;
}
free(new_path);
return true; return true;
} }