mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2025-12-22 23:33:04 +01:00
Fix #8754: Crash when downloading objects due to race condition
Use stack allocated buffer for string format arguments instead of the global argument buffer as this is performed on a background thread.
This commit is contained in:
committed by
Michael Steenbeek
parent
b957ad5e9e
commit
cf1a4c9d66
@@ -61,12 +61,13 @@ public:
|
|||||||
private:
|
private:
|
||||||
void UpdateProgress(const std::string& name, size_t count, size_t total)
|
void UpdateProgress(const std::string& name, size_t count, size_t total)
|
||||||
{
|
{
|
||||||
char str_downloading_objects[256];
|
char str_downloading_objects[256]{};
|
||||||
set_format_arg(0, int16_t, count);
|
uint8_t args[32]{};
|
||||||
set_format_arg(2, int16_t, total);
|
set_format_arg_on(args, 0, int16_t, count);
|
||||||
set_format_arg(4, char*, name.c_str());
|
set_format_arg_on(args, 2, int16_t, total);
|
||||||
|
set_format_arg_on(args, 4, char*, name.c_str());
|
||||||
|
|
||||||
format_string(str_downloading_objects, sizeof(str_downloading_objects), STR_DOWNLOADING_OBJECTS, gCommonFormatArgs);
|
format_string(str_downloading_objects, sizeof(str_downloading_objects), STR_DOWNLOADING_OBJECTS, args);
|
||||||
|
|
||||||
auto intent = Intent(WC_NETWORK_STATUS);
|
auto intent = Intent(WC_NETWORK_STATUS);
|
||||||
intent.putExtra(INTENT_EXTRA_MESSAGE, std::string(str_downloading_objects));
|
intent.putExtra(INTENT_EXTRA_MESSAGE, std::string(str_downloading_objects));
|
||||||
|
|||||||
Reference in New Issue
Block a user