Handle the case when bool serialization generates incorrect values on failure

Fix issue found by fuzzer
This commit is contained in:
Salvatore Mesoraca 2023-09-29 11:16:56 +02:00
parent 36da379b93
commit 22ae8731f2
No known key found for this signature in database
GPG Key ID: 0567E50A25403074

View File

@ -1690,9 +1690,15 @@ struct ConvertImplGenericFromString
}
catch (const Exception & e)
{
if (e.code() == ErrorCodes::CANNOT_PARSE_BOOL && typeid_cast<ColumnNullable *>(&column_to))
auto * nullable_column = typeid_cast<ColumnNullable *>(&column_to);
if (e.code() == ErrorCodes::CANNOT_PARSE_BOOL && nullable_column)
{
column_to.insertDefault();
auto & col_nullmap = nullable_column->getNullMapData();
if (col_nullmap.size() != nullable_column->size())
col_nullmap.push_back(0);
if (nullable_column->size() == column_from.size())
nullable_column->popBack(1);
nullable_column->insertDefault();
continue;
}
throw;