From 592b28f65f0873f75d91fd800acd03a7b79b1a02 Mon Sep 17 00:00:00 2001 From: Jukka Ojanen Date: Thu, 2 Sep 2021 15:57:22 +0300 Subject: [PATCH] Add tests for 32 bit build --- src/filehandling.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/filehandling.c b/src/filehandling.c index 2b6c09897..c890129c3 100644 --- a/src/filehandling.c +++ b/src/filehandling.c @@ -369,10 +369,7 @@ size_t hc_fread (void *ptr, size_t size, size_t nmemb, HCFILE *fp) #ifndef _WIN64 /* check 2 GB limit with 32 bit build */ - if (len >= INT32_MAX) - { - return n; - } + if (len >= INT32_MAX) return n; #endif if (len <= HCFILE_CHUNK_SIZE) @@ -414,6 +411,11 @@ size_t hc_fread (void *ptr, size_t size, size_t nmemb, HCFILE *fp) u64 len = (u64) size * nmemb; u64 pos = 0; + #if defined(_WIN) && !defined(_WIN64) + /* check 2 GB limit with 32 bit build */ + if (len >= INT32_MAX) return n; + #endif + /* assume success */ n = nmemb; @@ -440,6 +442,11 @@ size_t hc_fread (void *ptr, size_t size, size_t nmemb, HCFILE *fp) SRes res = SZ_OK; xzfile_t *xfp = fp->xfp; + #if defined(_WIN) && !defined(_WIN64) + /* check 2 GB limit with 32 bit build */ + if (outLen >= INT32_MAX) return n; + #endif + /* assume success */ n = nmemb;