diff --git a/setup.py b/setup.py index 90b0a5a..6fe8b0f 100755 --- a/setup.py +++ b/setup.py @@ -17,7 +17,7 @@ def read(fname): setup( name = 'pyminizip', - version = '0.2.4', + version = '0.2.4.1', description = 'A minizip wrapper - To create a password encrypted zip file in python.', author='Shin Aoyama', author_email = "smihica@gmail.com", diff --git a/src/py_minizip.c b/src/py_minizip.c index 99d25b1..c67d232 100644 --- a/src/py_minizip.c +++ b/src/py_minizip.c @@ -319,8 +319,14 @@ int _compress(const char** srcs, int src_num, const char** srcspath, int srcpath slash = &default_slash; } } - if (savefilepathnameinzip[filepathname_len-1] != *slash) - extra_len = 1; + + /* NOTE: + don't add slash if filepathname_len is zero (prefix is an empty string) + and avoid memory access violation */ + if (filepathname_len > 0) { + if (savefilepathnameinzip[filepathname_len-1] != *slash) + extra_len = 1; + } /* allocate buffer */ fullpathfileinzip = (char *)malloc(filename_len + filepathname_len + extra_len + 1); if (fullpathfileinzip == NULL) {