fix fuzzer segfault

This commit is contained in:
bharatnc 2022-02-19 08:41:21 -08:00
parent d9acbf480c
commit a4cf3303f9
3 changed files with 16 additions and 1 deletions

View File

@ -20,6 +20,7 @@ namespace ErrorCodes
{
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
extern const int ILLEGAL_COLUMN;
extern const int INCORRECT_DATA;
}
namespace
@ -74,6 +75,12 @@ public:
for (size_t row = 0; row < input_rows_count; ++row)
{
const UInt64 index = data[row];
CellBoundary boundary{};
auto err = cellToBoundary(index, &boundary);
if (err)
throw Exception(ErrorCodes::INCORRECT_DATA, "Incorrect H3 index: {}, error: {}", index, err);
Float64 res = cellAreaM2(index);
dst_data[row] = res;
}

View File

@ -20,6 +20,7 @@ namespace ErrorCodes
{
extern const int ILLEGAL_TYPE_OF_ARGUMENT;
extern const int ILLEGAL_COLUMN;
extern const int INCORRECT_DATA;
}
namespace
@ -64,7 +65,6 @@ public:
arguments[0].type->getName(),
1,
getName());
const auto & data = column->getData();
auto dst = ColumnVector<Float64>::create();
@ -74,6 +74,12 @@ public:
for (size_t row = 0; row < input_rows_count; ++row)
{
const UInt64 index = data[row];
CellBoundary boundary{};
auto err = cellToBoundary(index, &boundary);
if (err)
throw Exception(ErrorCodes::INCORRECT_DATA, "Incorrect H3 index: {}, error: {}", index, err);
Float64 res = cellAreaRads2(index);
dst_data[row] = res;
}

View File

@ -5,7 +5,9 @@ select h3ToParent(641573946153969375, arrayJoin([1,2]));
SELECT h3HexAreaM2(arrayJoin([1,2]));
SELECT h3HexAreaKm2(arrayJoin([1,2]));
SELECT h3CellAreaM2(arrayJoin([579205133326352383,589753847883235327,594082350283882495]));
SELECT NULL, toFloat64('-1'), -2147483648, h3CellAreaM2(arrayJoin([9223372036854775807, 65535, NULL])); -- { serverError 117 }
SELECT h3CellAreaRads2(arrayJoin([579205133326352383,589753847883235327,594082350283882495]));
SELECT NULL, toFloat64('-1'), -2147483648, h3CellAreaRads2(arrayJoin([9223372036854775807, 65535, NULL])); -- { serverError 117 }
SELECT h3GetResolution(arrayJoin([579205133326352383,589753847883235327,594082350283882495]));
SELECT h3EdgeAngle(arrayJoin([0,1,2]));
SELECT h3EdgeLengthM(arrayJoin([0,1,2]));