Merge pull request #49696 from evillique/ubsan-fuzzer

Fix member call on null pointer in fuzzer
This commit is contained in:
Nikolay Degterinsky 2023-05-10 00:03:50 +02:00 committed by GitHub
commit 7886353ed0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -862,7 +862,8 @@ bool Client::processWithFuzzing(const String & full_query)
const auto * tmp_pos = text_2.c_str(); const auto * tmp_pos = text_2.c_str();
const auto ast_3 = parseQuery(tmp_pos, tmp_pos + text_2.size(), const auto ast_3 = parseQuery(tmp_pos, tmp_pos + text_2.size(),
false /* allow_multi_statements */); false /* allow_multi_statements */);
const auto text_3 = ast_3->formatForErrorMessage(); const auto text_3 = ast_3 ? ast_3->formatForErrorMessage() : "";
if (text_3 != text_2) if (text_3 != text_2)
{ {
fmt::print(stderr, "Found error: The query formatting is broken.\n"); fmt::print(stderr, "Found error: The query formatting is broken.\n");
@ -877,7 +878,7 @@ bool Client::processWithFuzzing(const String & full_query)
fmt::print(stderr, "Text-1 (AST-1 formatted):\n'{}'\n", query_to_execute); fmt::print(stderr, "Text-1 (AST-1 formatted):\n'{}'\n", query_to_execute);
fmt::print(stderr, "AST-2 (Text-1 parsed):\n'{}'\n", ast_2->dumpTree()); fmt::print(stderr, "AST-2 (Text-1 parsed):\n'{}'\n", ast_2->dumpTree());
fmt::print(stderr, "Text-2 (AST-2 formatted):\n'{}'\n", text_2); fmt::print(stderr, "Text-2 (AST-2 formatted):\n'{}'\n", text_2);
fmt::print(stderr, "AST-3 (Text-2 parsed):\n'{}'\n", ast_3->dumpTree()); fmt::print(stderr, "AST-3 (Text-2 parsed):\n'{}'\n", ast_3 ? ast_3->dumpTree() : "");
fmt::print(stderr, "Text-3 (AST-3 formatted):\n'{}'\n", text_3); fmt::print(stderr, "Text-3 (AST-3 formatted):\n'{}'\n", text_3);
fmt::print(stderr, "Text-3 must be equal to Text-2, but it is not.\n"); fmt::print(stderr, "Text-3 must be equal to Text-2, but it is not.\n");