Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport #51499 to 23.4: Fix segfault in MathUnary #51630

Merged
merged 1 commit into from Jul 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/Functions/FunctionMathUnary.h
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
@@ -0,0 +1,2 @@
1
1
6 changes: 6 additions & 0 deletions tests/queries/0_stateless/02807_math_unary_crash.sql
@@ -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;