From c3aba5d9595e38379f1b6a227199a8c122d7d8aa Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Fri, 7 Apr 2023 07:39:49 +0100 Subject: [PATCH] Fix potential corruption when writing help file. When the standalone version of a binary, with its help file included as a resource, extracts that resource to write it to a disk, it could have accidentally skipped a byte in the middle if the WriteFile call in this loop had not managed to write the whole file in one go. (cherry picked from commit 775d969ca86aa9e9d6d51bd0ee88af8b6369942a) --- windows/help.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/windows/help.c b/windows/help.c index d087c722..5160b0d4 100644 --- a/windows/help.c +++ b/windows/help.c @@ -118,7 +118,7 @@ static bool load_chm_resource(void) created = true; const uint8_t *p = (const uint8_t *)chm_resource; - for (DWORD pos = 0; pos < chm_resource_size; pos++) { + for (DWORD pos = 0; pos < chm_resource_size ;) { DWORD to_write = chm_resource_size - pos; DWORD written = 0;