Fix UBSan

This commit is contained in:
Alexey Milovidov 2024-04-10 01:58:30 +02:00
parent c5ae1eec1e
commit 0e7d05e091

View File

@ -6,6 +6,8 @@
#include <Parsers/parseQuery.h>
#include <Common/UTF8Helpers.h>
#include <iostream>
namespace DB
{
@ -173,7 +175,8 @@ void highlight(const String & query, std::vector<replxx::Replxx::Color> & colors
/// Highlight the last error in red. If the parser failed or the lexer found an invalid token,
/// or if it didn't parse all the data (except, the data for INSERT query, which is legitimately unparsed)
if ((!parse_res || last_token.isError() || (!token_iterator->isEnd() && token_iterator->type != TokenType::Semicolon))
&& !(insert_data && expected.max_parsed_pos >= insert_data))
&& !(insert_data && expected.max_parsed_pos >= insert_data)
&& expected.max_parsed_pos >= prev)
{
pos += UTF8::countCodePoints(reinterpret_cast<const UInt8 *>(prev), expected.max_parsed_pos - prev);