From 19c52c3d6164553a16614f1366b8641426803b0c Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Thu, 30 Jul 2015 09:41:23 +0100 Subject: [PATCH] Fix command parsing bug Fixes #347 --- src/command_manager.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/command_manager.cc b/src/command_manager.cc index d2c08bf0..2ace81d5 100644 --- a/src/command_manager.cc +++ b/src/command_manager.cc @@ -100,7 +100,8 @@ String get_until_delimiter(StringView base, ByteCount& pos, char delimiter) } ++pos; } - str += base.substr(beg, pos - beg); + if (beg < length) + str += base.substr(beg, pos - beg); return str; } @@ -179,7 +180,7 @@ Token parse_percent_token(StringView line, ByteCount& pos) { const ByteCount length = line.length(); const ByteCount type_start = ++pos; - while (isalpha(line[pos])) + while (pos < length and isalpha(line[pos])) ++pos; StringView type_name = line.substr(type_start, pos - type_start);