Fix quoted value skipping

The return value wasn't checked and the code assumed that a non-end
iterator was always returned.
This commit is contained in:
Markus Mäkelä 2019-01-18 10:25:12 +02:00 committed by Johan Wikman
parent 9542641dae
commit 5b7c63fef7

View File

@ -1540,13 +1540,19 @@ std::string get_canonical(GWBUF* querybuf)
else if (*it == '\'' || *it == '"')
{
char c = *it;
it = find_char(std::next(it), buf.end(), c);
if ((it = find_char(std::next(it), buf.end(), c)) == buf.end())
{
break;
}
rval[i++] = '?';
}
else if (*it == '`')
{
auto start = it;
it = find_char(std::next(it), buf.end(), '`');
if ((it = find_char(std::next(it), buf.end(), '`')) == buf.end())
{
break;
}
std::copy(start, it, &rval[i]);
i += std::distance(start, it);
rval[i++] = '`';