Skip to content

Commit 2b10439

Browse files
cataphractclaude
andcommitted
Call archive_write_finish_entry after extraction to close file handle
Without this, arch_disk holds the extracted file open until the Archive object is destroyed. On Windows this blocks unlink() since object destructors run after register_shutdown_function callbacks. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 09777fd commit 2b10439

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

libarchive.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,13 @@ PHP_METHOD(libarchive_Archive, extractCurrent)
334334
if (!copy_data(arch_obj->archive, arch_obj->arch_disk)) {
335335
return;
336336
}
337+
338+
res = archive_write_finish_entry(arch_obj->arch_disk);
339+
if (res != ARCHIVE_OK) {
340+
zend_throw_exception_ex(except_ce, archive_errno(arch_obj->arch_disk),
341+
"Could not finish writing entry: %s",
342+
archive_error_string(arch_obj->arch_disk));
343+
}
337344
}
338345

339346
static bool copy_data(struct archive *ar, struct archive *aw)

0 commit comments

Comments
 (0)