From 5f958b3bd5c33282ab5b772854d96d4d2a6b72e6 Mon Sep 17 00:00:00 2001 From: Mathias Gumz Date: Sat, 12 Sep 2009 16:03:42 +0200 Subject: check for errno while parsing the deco mask --- src/WindowState.cc | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/WindowState.cc b/src/WindowState.cc index 50a88fc..1b8647a 100644 --- a/src/WindowState.cc +++ b/src/WindowState.cc @@ -23,7 +23,8 @@ #include "FbTk/StringUtil.hh" -#include +#include +#include bool WindowState::useBorder() const { return !fullscreen && maximized != MAX_FULL && deco_mask & DECORM_BORDER; @@ -92,10 +93,14 @@ int WindowState::getDecoMaskFromString(const std::string &str_label) { return DECOR_BORDER; if (label == "tab") return DECOR_TAB; + int mask = -1; - if ((str_label.size() > 1 && str_label[0] == '0' && str_label[1] == 'x') || - (str_label.size() > 0 && isdigit(str_label[0]))) - mask = strtol(str_label.c_str(), NULL, 0); + int tmp; + errno = 0; + tmp = strtol(str_label.c_str(), NULL, 0); + if (errno == 0) + mask = tmp; + return mask; } -- cgit v0.11.2