From 39b34a9109ca2a995bbe46a365efa105ecbdf968 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20L=C3=BCbking?= Date: Sun, 18 Sep 2016 15:06:10 +0200 Subject: fix segfault when completing ~ or . ie. w/o any / in the given path we'll get an irregular split point and thus out of bounds array access --- util/fbrun/FbRun.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/util/fbrun/FbRun.cc b/util/fbrun/FbRun.cc index b697187..19f6444 100644 --- a/util/fbrun/FbRun.cc +++ b/util/fbrun/FbRun.cc @@ -462,6 +462,10 @@ void FbRun::tabCompleteApps() { if (prefix.at(0) == '/' || prefix.at(0) == '.' || prefix.at(0) == '~') { // we're completing a directory, find subdirs split = prefix.find_last_of('/'); + if (split == std::string::npos) { + split = prefix.size(); + prefix.append("/"); + } prefix = prefix.substr(0, split+1); if (prefix != m_last_completion_path) { m_files.clear(); -- cgit v0.11.2