Skip to content

Commit 9936160

Browse files
committed
Don’t check last character of empty strings.
Fixes #511
1 parent 17f10b9 commit 9936160

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

THANKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ Gerard ODonnell
6767
Giovanni
6868
gk7huki <gk7huki@gmail.com>
6969
Hanno Böck <hanno@hboeck.de>
70+
Harrison Green
7071
HeeMyung
7172
Heiko Becker
7273
Heiko Hund <heiko@ist.eigentlich.net>

lib/zip_file_rename.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ zip_file_rename(zip_t *za, zip_uint64_t idx, const char *name, zip_flags_t flags
5555
if ((old_name = zip_get_name(za, idx, 0)) == NULL)
5656
return -1;
5757

58-
new_is_dir = (name != NULL && name[strlen(name) - 1] == '/');
59-
old_is_dir = (old_name[strlen(old_name) - 1] == '/');
58+
new_is_dir = (name != NULL && name[0] != '\0' && name[strlen(name) - 1] == '/');
59+
old_is_dir = (old_name[0] != '\0' && old_name[strlen(old_name) - 1] == '/');
6060

6161
if (new_is_dir != old_is_dir) {
6262
zip_error_set(&za->error, ZIP_ER_INVAL, 0);

0 commit comments

Comments
 (0)