@@ -789,12 +789,14 @@ @throw [OFNotOpenException exceptionWithObject: self]; if (_atEndOfStream) return 0; - if (sizeof(length) >= sizeof(uint64_t) && length > UINT64_MAX) +#if SIZE_MAX >= UINT64_MAX + if (length > UINT64_MAX) @throw [OFOutOfRangeException exception]; +#endif if ((uint64_t)length > _toRead) length = (size_t)_toRead; ret = [_decompressedStream readIntoBuffer: buffer @@ -848,12 +850,16 @@ - (size_t)lowlevelWriteBuffer: (const void *)buffer length: (size_t)length { size_t bytesWritten; - if ((sizeof(length) >= sizeof(int64_t) && length > INT64_MAX) || - INT64_MAX - _bytesWritten < (int64_t)length) +#if SIZE_MAX >= INT64_MAX + if (length > INT64_MAX) + @throw [OFOutOfRangeException exception]; +#endif + + if (INT64_MAX - _bytesWritten < (int64_t)length) @throw [OFOutOfRangeException exception]; bytesWritten = [_stream writeBuffer: buffer length: length];