diff --git a/src/kits/storage/kernel_interface.POSIX.cpp b/src/kits/storage/kernel_interface.POSIX.cpp index 2e464fc711..196a6eb86e 100644 --- a/src/kits/storage/kernel_interface.POSIX.cpp +++ b/src/kits/storage/kernel_interface.POSIX.cpp @@ -1112,11 +1112,13 @@ StorageKit::get_app_path(char *buffer) image_info info; int32 cookie = 0; bool found = false; - while (!found && get_next_image_info(0, &cookie, &info) == B_OK) { - if (info.type == B_APP_IMAGE) { - strncpy(buffer, info.name, B_PATH_NAME_LENGTH); - buffer[B_PATH_NAME_LENGTH] = 0; - found = true; + if (error == B_OK) { + while (!found && get_next_image_info(0, &cookie, &info) == B_OK) { + if (info.type == B_APP_IMAGE) { + strncpy(buffer, info.name, B_PATH_NAME_LENGTH); + buffer[B_PATH_NAME_LENGTH] = 0; + found = true; + } } } if (error == B_OK && !found)