fix-kdb-complete-heap-overflow: avoid potential overflow when string not found
@@ -354,7 +354,11 @@ bool CompleteCommand::filterCascading (string const & argument, pair<Key, pair<i
{
// For a cascading key completion, ignore the preceding namespace
const string test = current.first.getFullName ();
- const int cascadationOffset = test.find ("/");
+ int cascadationOffset = test.find ("/");
+ if (cascadationOffset == string::npos)
+ {
+ cascadationOffset = 0;
+ }
return argument.size () <= test.size () && equal (argument.begin (), argument.end (), test.begin () + cascadationOffset);
}
