Skip to content

This PR replaces the use of ftell() with platform-correct 64-bit file…#3064

Open
nidu-ninja wants to merge 2 commits intoAOMediaCodec:mainfrom
nidu-ninja:fix/64bit-file-size-detection
Open

This PR replaces the use of ftell() with platform-correct 64-bit file…#3064
nidu-ninja wants to merge 2 commits intoAOMediaCodec:mainfrom
nidu-ninja:fix/64bit-file-size-detection

Conversation

@nidu-ninja
Copy link

@nidu-ninja nidu-ninja commented Feb 27, 2026

… APIs when determining file size in avifIOCreateFileReader().
The previous implementation relied on long, which may be 32-bit on some platforms, causing incorrect file size detection for files larger than 2GB.

The change ensures consistent and correct large-file handling across Windows and POSIX systems without altering public APIs or parsing behavior.

… APIs when determining file size in avifIOCreateFileReader().
return NULL;
}
uint64_t fileSize = (uint64_t)fileSizeSigned;
#endif
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NiDU-NINJA: Thank you for the pull request. We are in the middle of creating the libavif v1.4.0 release. I will review this PR next week.

Some preliminary comments.

  1. It is disappointing that C23 did not address the use of the long type in fseek() and ftell().
  2. I think your PR is correct. Since the fseek() call at line 113 in avifIOFileReaderRead() needs the same treatment, it would be better to create libavif's own wrapper functions for the fseek() and ftell() variants that support large files.
    • We can be POSIX-centric and provide fseeko() and ftello() wrappers for Windows, or
    • we can be neutral and provide avifFseek64() and avifFtell64() for POSIX and Windows.
    • I can take care of the wrappers in a follow-up PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants