diff --git a/shared/src/native-src/util.cpp b/shared/src/native-src/util.cpp index cd8963337a2f..8f2b3d2034ba 100644 --- a/shared/src/native-src/util.cpp +++ b/shared/src/native-src/util.cpp @@ -285,8 +285,12 @@ namespace shared UUID uuid; UuidCreate(&uuid); - unsigned char* str; - UuidToStringA(&uuid, &str); + unsigned char* str = nullptr; + if (UuidToStringA(&uuid, &str) != RPC_S_OK) + { + // str is left untouched on failure, so there is nothing to free + return GenerateUuidV4(); + } std::string s((char*) str);