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
parent 2e95812b71
commit 28644e9626
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19

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++] = '`';