From 96c9c8923861dfe33e21e4459b491a7672cb2c63 Mon Sep 17 00:00:00 2001 From: Lion Kortlepel Date: Sun, 22 Sep 2024 19:52:52 +0200 Subject: [PATCH] add extra layer of checks for data races in download yeah --- src/Network/Resources.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/Network/Resources.cpp b/src/Network/Resources.cpp index 57fb8d9..aa47453 100644 --- a/src/Network/Resources.cpp +++ b/src/Network/Resources.cpp @@ -217,6 +217,13 @@ std::vector MultiDownload(SOCKET MSock, SOCKET DSock, uint64_t Size, const return {}; } + // ensure that GRcv is good before joining the async update thread + GRcv = MData.size() + DData.size(); + if (GRcv != Size) { + error("Something went wrong during download; didn't get enough data. Expected " + std::to_string(Size) + " bytes, got " + std::to_string(GRcv) + " bytes instead"); + return {}; + } + Au.join(); std::vector Result{};