summaryrefslogtreecommitdiff
path: root/platform/x11
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2017-08-27 02:10:56 +0200
committerGitHub <noreply@github.com>2017-08-27 02:10:56 +0200
commit612099e3771578fd3e78171f1ca1444f6c41cef3 (patch)
treec4173d550b3148c1223f67de0a8836dc744e831a /platform/x11
parentea55b400d908c01345a974cae82d8a8720e9904d (diff)
parent7a07895920196c00d1ee14187e4ccdb2a6f0d0b9 (diff)
Merge pull request #10591 from Rubonnek/possible-null-ptr-dereference
Added/Fixed null pointer checks
Diffstat (limited to 'platform/x11')
-rw-r--r--platform/x11/os_x11.cpp14
-rw-r--r--platform/x11/power_x11.cpp13
2 files changed, 12 insertions, 15 deletions
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp
index 008b3ab615..8332b2f51c 100644
--- a/platform/x11/os_x11.cpp
+++ b/platform/x11/os_x11.cpp
@@ -116,24 +116,22 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au
/** XLIB INITIALIZATION **/
x11_display = XOpenDisplay(NULL);
+ char *modifiers = NULL;
Bool xkb_dar = False;
if (x11_display) {
XAutoRepeatOn(x11_display);
xkb_dar = XkbSetDetectableAutoRepeat(x11_display, True, NULL);
- }
-
- char *modifiers = NULL;
- // Try to support IME if detectable auto-repeat is supported
-
- if (xkb_dar == True) {
+ // Try to support IME if detectable auto-repeat is supported
+ if (xkb_dar == True) {
// Xutf8LookupString will be used later instead of XmbLookupString before
// the multibyte sequences can be converted to unicode string.
#ifdef X_HAVE_UTF8_STRING
- modifiers = XSetLocaleModifiers("");
+ modifiers = XSetLocaleModifiers("");
#endif
+ }
}
if (modifiers == NULL) {
@@ -141,8 +139,6 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au
WARN_PRINT("IME is disabled");
}
modifiers = XSetLocaleModifiers("@im=none");
- }
- if (modifiers == NULL) {
WARN_PRINT("Error setting locale modifiers");
}
diff --git a/platform/x11/power_x11.cpp b/platform/x11/power_x11.cpp
index 8e69a2223f..72fa5cf380 100644
--- a/platform/x11/power_x11.cpp
+++ b/platform/x11/power_x11.cpp
@@ -58,6 +58,7 @@ Adapted from corresponding SDL 2.0 code.
#include <stdio.h>
#include <unistd.h>
+#include "core/error_macros.h"
#include <dirent.h>
#include <fcntl.h>
#include <sys/stat.h>
@@ -254,9 +255,9 @@ bool PowerX11::GetPowerInfo_Linux_proc_acpi() {
this->power_state = POWERSTATE_UNKNOWN;
dirp->change_dir(proc_acpi_battery_path);
- dirp->list_dir_begin();
+ Error err = dirp->list_dir_begin();
- if (dirp == NULL) {
+ if (err != OK) {
return false; /* can't use this interface. */
} else {
node = dirp->get_next();
@@ -268,8 +269,8 @@ bool PowerX11::GetPowerInfo_Linux_proc_acpi() {
}
dirp->change_dir(proc_acpi_ac_adapter_path);
- dirp->list_dir_begin();
- if (dirp == NULL) {
+ err = dirp->list_dir_begin();
+ if (err != OK) {
return false; /* can't use this interface. */
} else {
node = dirp->get_next();
@@ -438,9 +439,9 @@ bool PowerX11::GetPowerInfo_Linux_sys_class_power_supply(/*PowerState *state, in
DirAccess *dirp = DirAccess::create(DirAccess::ACCESS_FILESYSTEM);
dirp->change_dir(base);
- dirp->list_dir_begin();
+ Error err = dirp->list_dir_begin();
- if (!dirp) {
+ if (err != OK) {
return false;
}