diff options
author | Peter Kim <pk15950@gmail.com> | 2022-06-17 11:27:30 +0300 |
---|---|---|
committer | Peter Kim <pk15950@gmail.com> | 2022-06-17 11:27:30 +0300 |
commit | a39532670f6b668da7be5810fb1f844b82feeba3 (patch) | |
tree | 4d6a40f6c362ca1d9b7c7031527e6e54a62589e6 /release/scripts/modules/blend_render_info.py | |
parent | 7948150ca3683dc326c37609ded322d54b832d0d (diff) | |
parent | 10981bc8c092dda48ed5228cc19108513035abf0 (diff) |
Merge branch 'master' into xr-dev
Diffstat (limited to 'release/scripts/modules/blend_render_info.py')
-rwxr-xr-x | release/scripts/modules/blend_render_info.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/release/scripts/modules/blend_render_info.py b/release/scripts/modules/blend_render_info.py index 4ba818a19e5..37c5f6dd3ba 100755 --- a/release/scripts/modules/blend_render_info.py +++ b/release/scripts/modules/blend_render_info.py @@ -85,7 +85,13 @@ def _read_blend_rend_chunk_from_file(blendfile, filepath): sizeof_bhead = 24 if is_64_bit else 20 - while len(bhead_id := blendfile.read(4)) == 4: + # Should always be 4, but a malformed/corrupt file may be less. + while (bhead_id := blendfile.read(4)) != b'ENDB': + + if len(bhead_id) != 4: + sys.stderr.write("Unable to read until ENDB block (corrupt file): %s\n" % filepath) + break + sizeof_data_left = struct.unpack('>i' if is_big_endian else '<i', blendfile.read(4))[0] # 4 from the `head_id`, another 4 for the size of the BHEAD. sizeof_bhead_left = sizeof_bhead - 8 @@ -107,8 +113,12 @@ def _read_blend_rend_chunk_from_file(blendfile, filepath): scenes.append((start_frame, end_frame, scene_name)) - if sizeof_data_left != 0: + if sizeof_data_left > 0: blendfile.seek(sizeof_data_left, SEEK_CUR) + elif sizeof_data_left < 0: + # Very unlikely, but prevent attempting to further parse corrupt data. + sys.stderr.write("Error calculating next block (corrupt file): %s\n" % filepath) + break return scenes |