Check for zero length path in mz_path_has_slash

Fix for https://github.com/zlib-ng/minizip-ng/issues/739
This commit is contained in:
pmqs 2023-11-12 16:53:51 +00:00 committed by Nathan Moinvaziri
parent 42b6b8997c
commit 3417608874

View file

@ -68,7 +68,7 @@ int32_t mz_path_remove_slash(char *path) {
int32_t mz_path_has_slash(const char *path) {
int32_t path_len = (int32_t)strlen(path);
if (path[path_len - 1] != '\\' && path[path_len - 1] != '/')
if (path_len > 0 && path[path_len - 1] != '\\' && path[path_len - 1] != '/')
return MZ_EXIST_ERROR;
return MZ_OK;
}