summaryrefslogtreecommitdiff
path: root/src/managers/input/InputManager.cpp
diff options
context:
space:
mode:
authormemchr <118117622+memchr@users.noreply.github.com>2023-08-25 15:21:55 +0000
committerGitHub <noreply@github.com>2023-08-25 17:21:55 +0200
commitf0da0b0be4c70eeb94e44847eed9632f01f49807 (patch)
treec735b8f3f9454caca0b700810d144897f716bc63 /src/managers/input/InputManager.cpp
parent3a1f30519bb3ae265fc4f9cc720513217e928fdb (diff)
input: improved path handling; null check return value of fopen. (#3061)
Diffstat (limited to 'src/managers/input/InputManager.cpp')
-rw-r--r--src/managers/input/InputManager.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/src/managers/input/InputManager.cpp b/src/managers/input/InputManager.cpp
index 7bc84b82..80869a77 100644
--- a/src/managers/input/InputManager.cpp
+++ b/src/managers/input/InputManager.cpp
@@ -784,10 +784,9 @@ void CInputManager::applyConfigToKeyboard(SKeyboard* pKeyboard) {
if (!FILEPATH.empty()) {
auto path = absolutePath(FILEPATH, g_pConfigManager->configCurrentPath);
- if (!std::filesystem::exists(path))
- Debug::log(ERR, "input:kb_file= file doesnt exist");
+ if (FILE* const KEYMAPFILE = fopen(path.c_str(), "r"); !KEYMAPFILE)
+ Debug::log(ERR, "Cannot open input:kb_file= file for reading");
else {
- FILE* const KEYMAPFILE = fopen(FILEPATH.c_str(), "r");
KEYMAP = xkb_keymap_new_from_file(CONTEXT, KEYMAPFILE, XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS);
fclose(KEYMAPFILE);
}