From aab8da25ad2c3e6d2df03abbc8e35c1725938c40 Mon Sep 17 00:00:00 2001 From: qarmin Date: Tue, 23 Jul 2019 09:14:31 +0200 Subject: Fix some code found by Coverity Scan and PVS Studio --- platform/x11/joypad_linux.cpp | 2 ++ platform/x11/power_x11.cpp | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'platform/x11') diff --git a/platform/x11/joypad_linux.cpp b/platform/x11/joypad_linux.cpp index e6328ee14d..4242952374 100644 --- a/platform/x11/joypad_linux.cpp +++ b/platform/x11/joypad_linux.cpp @@ -513,6 +513,8 @@ void JoypadLinux::process_joypads() { break; default: + if (ev.code >= MAX_ABS) + return; if (joy->abs_map[ev.code] != -1 && joy->abs_info[ev.code]) { InputDefault::JoyAxis value = axis_correct(joy->abs_info[ev.code], ev.value); joy->curr_axis[joy->abs_map[ev.code]] = value; diff --git a/platform/x11/power_x11.cpp b/platform/x11/power_x11.cpp index 758bd84114..c33c77e16b 100644 --- a/platform/x11/power_x11.cpp +++ b/platform/x11/power_x11.cpp @@ -268,9 +268,7 @@ bool PowerX11::GetPowerInfo_Linux_proc_acpi() { check_proc_acpi_battery(node.utf8().get_data(), &have_battery, &charging /*, seconds, percent*/); node = dirp->get_next(); } - memdelete(dirp); } - dirp->change_dir(proc_acpi_ac_adapter_path); err = dirp->list_dir_begin(); if (err != OK) { @@ -281,7 +279,6 @@ bool PowerX11::GetPowerInfo_Linux_proc_acpi() { check_proc_acpi_ac_adapter(node.utf8().get_data(), &have_ac); node = dirp->get_next(); } - memdelete(dirp); } if (!have_battery) { @@ -294,6 +291,7 @@ bool PowerX11::GetPowerInfo_Linux_proc_acpi() { this->power_state = OS::POWERSTATE_ON_BATTERY; } + memdelete(dirp); return true; /* definitive answer. */ } -- cgit v1.2.3