aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMichael <[email protected]>2023-08-08 07:07:15 -0700
committerGitHub <[email protected]>2023-08-08 16:07:15 +0200
commitad3b8dddf993736fe2d716e4cdc5c079e511da2e (patch)
tree33403155ebcc1781f229d9f8ba587c51354f2240
parentcebab759d52747c2067217d93096b47281722e57 (diff)
downloadHyprland-ad3b8dddf993736fe2d716e4cdc5c079e511da2e.tar.gz
Hyprland-ad3b8dddf993736fe2d716e4cdc5c079e511da2e.zip
keybinds: Only call fclose() when we have a valid file. (#2908)
Signed-off-by: Michael Pacheco <[email protected]>
-rw-r--r--src/managers/KeybindManager.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/managers/KeybindManager.cpp b/src/managers/KeybindManager.cpp
index 94e0dfd4..8c0cfab4 100644
--- a/src/managers/KeybindManager.cpp
+++ b/src/managers/KeybindManager.cpp
@@ -141,11 +141,12 @@ void CKeybindManager::updateXKBTranslationState() {
xkb_rule_names rules = {.rules = RULES.c_str(), .model = MODEL.c_str(), .layout = LAYOUT.c_str(), .variant = VARIANT.c_str(), .options = OPTIONS.c_str()};
const auto PCONTEXT = xkb_context_new(XKB_CONTEXT_NO_FLAGS);
- FILE* const KEYMAPFILE = fopen(FILEPATH.c_str(), "r");
+ FILE* const KEYMAPFILE = FILEPATH == "" ? NULL : fopen(FILEPATH.c_str(), "r");
auto PKEYMAP = FILEPATH == "" ? xkb_keymap_new_from_names(PCONTEXT, &rules, XKB_KEYMAP_COMPILE_NO_FLAGS) :
xkb_keymap_new_from_file(PCONTEXT, KEYMAPFILE, XKB_KEYMAP_FORMAT_TEXT_V1, XKB_KEYMAP_COMPILE_NO_FLAGS);
- fclose(KEYMAPFILE);
+ if (KEYMAPFILE)
+ fclose(KEYMAPFILE);
if (!PKEYMAP) {
g_pHyprError->queueCreate("[Runtime Error] Invalid keyboard layout passed. ( rules: " + RULES + ", model: " + MODEL + ", variant: " + VARIANT + ", options: " + OPTIONS +