From 58fa6eb1f9a0fad94b59b4d2aefc0f09bc1372f0 Mon Sep 17 00:00:00 2001 From: selurvedu Date: Mon, 20 Jul 2015 00:25:46 +0300 Subject: [PATCH] Support symbol strings with '_' in place of '+' This fixes a segfault that occurs for the following reason: - In XKeyboard::initializeXkb(), the XkbSymbolParser::parse() is called with three arguments - string to process (symName), vector to push symbol names to (_symbolNames) and vector to push variant names to (_variantNames). - In XkbSymbolParser::parse(), it looks for char '+' in symName string, but Xkb may use '_' instead when creating that string. If the char is not found, parse() doesn't append anything to vectors and they remain empty. - Later, XKeyboard::initializeXkb() tries to access nonexistent data in _symbolNames, which causes a segmentation fault (on lines 162-163). --- XKeyboard.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/XKeyboard.cpp b/XKeyboard.cpp index c514980..84d08f2 100644 --- a/XKeyboard.cpp +++ b/XKeyboard.cpp @@ -327,7 +327,7 @@ void XkbSymbolParser::parse(const std::string& symbols, StringVector& symbolList for (size_t i = 0; i < symbols.size(); i++) { char ch = symbols[i]; - if (ch == '+') { + if (ch == '+' || ch == '_') { if (inSymbol) { if (isXkbLayoutSymbol(curSymbol)) { symbolList.push_back(curSymbol);