mirror of
https://github.com/vlang/v.git
synced 2025-09-12 08:57:09 -04:00
szip: fix panic on empty files (#24335)
This commit is contained in:
parent
57b815f96d
commit
8fc7aeca38
@ -183,7 +183,7 @@ pub fn (mut zentry Zip) crc32() u32 {
|
||||
|
||||
// write_entry compresses an input buffer for the current zip entry.
|
||||
pub fn (mut zentry Zip) write_entry(data []u8) ! {
|
||||
if int(data[0] & 0xff) == -1 {
|
||||
if data.len > 0 && int(data[0] & 0xff) == -1 {
|
||||
return error('szip: cannot write entry')
|
||||
}
|
||||
res := C.zip_entry_write(zentry, data.data, data.len)
|
||||
|
@ -170,3 +170,11 @@ fn test_zip_folder_omit_empty_directories() {
|
||||
assert (os.read_file(fpath5)!) == '5'
|
||||
assert (os.read_file(fpath6)!) == '6'
|
||||
}
|
||||
|
||||
fn test_zip_folder_empty_file() {
|
||||
cleanup()
|
||||
os.mkdir_all(test_path)!
|
||||
os.write_file('${test_path}/test.txt', '')! // Empty file
|
||||
szip.zip_folder(test_path, test_dir_zip)!
|
||||
assert os.exists(test_dir_zip)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user