Declare the sizeHint field of avifIO as uint64_t
Since the sizeHint field of the avifIO struct may represent the size of
a file, it should be declared as uint64_t in order to support large
files (files larger than 2 GB). The current size_t type is 32 bits on
32-bit platforms.
Since the 'offset' parameter of the avifIO read() function is uint64_t,
sizeHint should be of the same type. In other words, file offset and
file size should have the same type. (I assume 'offset' is declared as
uint64_t in order to support large files.)
In avifIOCreateFileReader(), check for ftell() failure to avoid casting
-1 to an unsigned type (whether it's size_t or uint64_t).
Also declared the 'data' parameter of the avifIO write() function as a
const pointer.
diff --git a/src/read.c b/src/read.c
index 6b07664..379a848 100644
--- a/src/read.c
+++ b/src/read.c
@@ -331,7 +331,7 @@
avifFree(decodeInput);
}
-static avifBool avifCodecDecodeInputGetSamples(avifCodecDecodeInput * decodeInput, avifSampleTable * sampleTable, size_t sizeHint)
+static avifBool avifCodecDecodeInputGetSamples(avifCodecDecodeInput * decodeInput, avifSampleTable * sampleTable, uint64_t sizeHint)
{
uint32_t sampleSizeIndex = 0;
for (uint32_t chunkIndex = 0; chunkIndex < sampleTable->chunks.count; ++chunkIndex) {
@@ -371,7 +371,7 @@
if (sampleSize > UINT64_MAX - sampleOffset) {
return AVIF_FALSE;
}
- if (sizeHint && ((sampleOffset + sampleSize) > (uint64_t)sizeHint)) {
+ if (sizeHint && ((sampleOffset + sampleSize) > sizeHint)) {
return AVIF_FALSE;
}