Skip to content

Commit 5ab83d6

Browse files
authored
Merge pull request #53 from mrnoname1000/unixlauncher-which-fix
unixlauncher.c: Fix bounds check in which
2 parents 0c382cb + ceee0e7 commit 5ab83d6

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

unixlauncher.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ static char *which(const char *const executable) {
3333
dirs[dirs_length] = ':';
3434

3535
size_t dir_head = 0;
36-
size_t i = 0;
37-
do {
36+
for (size_t i = 0; i <= dirs_length; i++) {
3837
if (dirs[i] == ':') {
3938
// Declare convenient path variables
4039
char *const dir = dirs + dir_head;
@@ -61,7 +60,7 @@ static char *which(const char *const executable) {
6160

6261
dir_head = i + 1;
6362
}
64-
} while (dirs[i++]);
63+
};
6564

6665
// Lookup has failed, free if necessary and return NULL
6766
if (exe_path != NULL) {

0 commit comments

Comments
 (0)