Skip to content

Commit

Permalink
Backport #51499 to 23.3: Fix segfault in MathUnary
Browse files Browse the repository at this point in the history
  • Loading branch information
robot-clickhouse committed Jun 29, 2023
1 parent bc683c1 commit 4070c25
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Functions/FunctionMathUnary.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,8 @@ class FunctionMathUnary : public IFunction
using ColVecType = ColumnVectorOrDecimal<Type>;

const auto col_vec = checkAndGetColumn<ColVecType>(col.column.get());
if (col_vec == nullptr)
return false;
return (res = execute<Type, ReturnType>(col_vec)) != nullptr;
};

Expand Down
2 changes: 2 additions & 0 deletions tests/queries/0_stateless/02807_math_unary_crash.reference
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
1
1
6 changes: 6 additions & 0 deletions tests/queries/0_stateless/02807_math_unary_crash.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
DROP TABLE IF EXISTS t10;
CREATE TABLE t10 (`c0` Int32) ENGINE = MergeTree ORDER BY tuple();
INSERT INTO t10 (c0) FORMAT Values (-1);
SELECT 1 FROM t10 GROUP BY erf(-sign(t10.c0));
SELECT 1 FROM t10 GROUP BY -sign(t10.c0);
DROP TABLE t10;

0 comments on commit 4070c25

Please sign in to comment.