-
-
Notifications
You must be signed in to change notification settings - Fork 21.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix decompression functions not returning errcodes #58278
Conversation
core/io/file_access_compressed.cpp
Outdated
@@ -305,7 +308,8 @@ uint64_t FileAccessCompressed::get_buffer(uint8_t *p_dst, uint64_t p_length) con | |||
if (read_block < read_block_count) { | |||
//read another block of compressed data | |||
f->get_buffer(comp_buffer.ptrw(), read_blocks[read_block].csize); | |||
Compression::decompress(buffer.ptrw(), read_blocks.size() == 1 ? read_total : block_size, comp_buffer.ptr(), read_blocks[read_block].csize, cmode); | |||
int err = Compression::decompress(buffer.ptrw(), read_blocks.size() == 1 ? read_total : block_size, comp_buffer.ptr(), read_blocks[read_block].csize, cmode); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be ret
for consistency with other checks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed 👍
core/io/file_access_compressed.cpp
Outdated
@@ -125,10 +125,11 @@ Error FileAccessCompressed::_open(const String &p_path, int p_mode_flags) { | |||
char rmagic[5]; | |||
f->get_buffer((uint8_t *)rmagic, 4); | |||
rmagic[4] = 0; | |||
if (magic != rmagic || open_after_magic(f) != OK) { | |||
Error err = ERR_FILE_UNRECOGNIZED; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shadows previous err
:
Error err = ERR_FILE_UNRECOGNIZED; | |
err = ERR_FILE_UNRECOGNIZED; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed 👍
core/io/file_access_compressed.cpp
Outdated
int ret = Compression::decompress(buffer.ptrw(), read_blocks.size() == 1 ? read_total : block_size, comp_buffer.ptr(), read_blocks[read_block].csize, cmode); | ||
ERR_FAIL_COND_V_MSG(ret == -1, 0, "Compressed file is corrupt."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shadows ret
which is actually the decompression result.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed, I picked total
as a more sensible name than err
for this one.
cf6bbfb
to
61790a0
Compare
Thanks! |
Cherry-picked for 3.5. |
Cherry-picked for 3.4.3. |
Compression::decompress
returns -1 on error scenarios. This was not being propagated to let the user know there was an error while reading compressed files.Fixes #57049