mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
Fix crash in BLI_mmap.cc on WIN32
Address an issue running blender 5.x on the otoy rndr network where it crashes when loading a scene. Reset the file pointer to the beginning of the file in case we are closing it using the windows file handle due to failure of reading it with memory map. This keeps everything consistent for later opening that file again. Ref !155823
This commit is contained in:
parent
96bbff21af
commit
956fd000a2
1 changed files with 6 additions and 1 deletions
|
|
@ -371,7 +371,12 @@ BLI_mmap_file *BLI_mmap_open(int fd)
|
|||
static std::atomic_size_t id_counter = 0;
|
||||
|
||||
void *memory, *handle = nullptr;
|
||||
const size_t length = BLI_lseek(fd, 0, SEEK_END);
|
||||
/* It's important not to use `BLI_lseek` here because in case we fail to use mmap and returning
|
||||
* nullptr, the calling function is not closing the file using the file descriptor means next
|
||||
* time the file is read the filepointer is still pointing to the end. This is not an issue for
|
||||
* blender but it throws off the virtual filesystem when blender is running on the
|
||||
* render-network. See PR !155823 for details. */
|
||||
const size_t length = BLI_file_descriptor_size(fd);
|
||||
if (UNLIKELY(length == size_t(-1))) {
|
||||
return nullptr;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue