Skip to content

Commit bb935ff

Browse files
committed
Fixed bug #64452 Zip PHPTs crash intermittently
1 parent 8d199c7 commit bb935ff

3 files changed

Lines changed: 17 additions & 4 deletions

File tree

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ PHP NEWS
1717
- DateTime
1818
. Fixed bug #62852 (Unserialize Invalid Date causes crash). (Anatol)
1919

20+
- Zip:
21+
. Bug #64452 (Zip crash intermittently). (Anatol)
22+
2023

2124
14 Mar 2013, PHP 5.3.23
2225

ext/zip/lib/zip_close.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ zip_close(struct zip *za)
8888
if (za == NULL)
8989
return -1;
9090

91+
if (za->zp == NULL)
92+
return -1;
93+
9194
if (!_zip_changed(za, &survivors)) {
9295
_zip_free(za);
9396
return 0;
@@ -164,9 +167,10 @@ zip_close(struct zip *za)
164167
for (j=0; j<survivors; j++) {
165168
i = filelist[j].idx;
166169

170+
_zip_dirent_init(&de);
171+
167172
/* create new local directory entry */
168173
if (ZIP_ENTRY_DATA_CHANGED(za->entry+i) || new_torrentzip) {
169-
_zip_dirent_init(&de);
170174

171175
if (zip_get_archive_flag(za, ZIP_AFL_TORRENT, 0))
172176
_zip_dirent_torrent_normalize(&de);

ext/zip/lib/zip_dirent.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,17 @@ _zip_cdir_write(struct zip_cdir *cd, FILE *fp, struct zip_error *error)
157157
void
158158
_zip_dirent_finalize(struct zip_dirent *zde)
159159
{
160-
free(zde->filename);
160+
if (zde->filename_len > 0) {
161+
free(zde->filename);
162+
}
161163
zde->filename = NULL;
162-
free(zde->extrafield);
164+
if (zde->extrafield_len > 0) {
165+
free(zde->extrafield);
166+
}
163167
zde->extrafield = NULL;
164-
free(zde->comment);
168+
if (zde->comment_len > 0) {
169+
free(zde->comment);
170+
}
165171
zde->comment = NULL;
166172
}
167173

0 commit comments

Comments
 (0)