Prevent variable underflow in path_end_with_separator

This commit is contained in:
Michał Janiszewski 2016-11-22 17:15:03 +01:00 committed by GitHub
parent 349ca774ca
commit 2ec1fd0378
1 changed files with 1 additions and 1 deletions

View File

@ -146,7 +146,7 @@ void path_end_with_separator(utf8 *path, size_t size) {
size_t length = strnlen(path, size);
if (length >= size - 1) return;
if (path[length - 1] != *PATH_SEPARATOR)
if ((length == 0) || (path[length - 1] != *PATH_SEPARATOR))
safe_strcat(path, PATH_SEPARATOR, size);
}