From 600489aa33a032bed755651135ffd731e6d1b03b Mon Sep 17 00:00:00 2001 From: Richard Wesley <13156216+hawkfish@users.noreply.github.com> Date: Thu, 4 Jan 2024 13:53:01 -0800 Subject: [PATCH] Issue #10140: NULL Constant Lists Don't copy the data for a NULL constant list as it may not exist. fixes: #10140 fixes: duckdblabs/duckdb-internal#1006 --- src/function/cast/list_casts.cpp | 11 +++++++---- test/fuzzer/duckfuzz/list_try_cast.test | 6 ++++++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/function/cast/list_casts.cpp b/src/function/cast/list_casts.cpp index c0911b28d27f..13513e346747 100644 --- a/src/function/cast/list_casts.cpp +++ b/src/function/cast/list_casts.cpp @@ -38,11 +38,14 @@ bool ListCast::ListToListCast(Vector &source, Vector &result, idx_t count, CastP // only handle constant and flat vectors here for now if (source.GetVectorType() == VectorType::CONSTANT_VECTOR) { result.SetVectorType(source.GetVectorType()); - ConstantVector::SetNull(result, ConstantVector::IsNull(source)); + const bool is_null = ConstantVector::IsNull(source); + ConstantVector::SetNull(result, is_null); - auto ldata = ConstantVector::GetData(source); - auto tdata = ConstantVector::GetData(result); - *tdata = *ldata; + if (!is_null) { + auto ldata = ConstantVector::GetData(source); + auto tdata = ConstantVector::GetData(result); + *tdata = *ldata; + } } else { source.Flatten(count); result.SetVectorType(VectorType::FLAT_VECTOR); diff --git a/test/fuzzer/duckfuzz/list_try_cast.test b/test/fuzzer/duckfuzz/list_try_cast.test index 23453162344f..61c510461159 100644 --- a/test/fuzzer/duckfuzz/list_try_cast.test +++ b/test/fuzzer/duckfuzz/list_try_cast.test @@ -26,3 +26,9 @@ query I SELECT TRY_CAST(v AS INTEGER[]) FROM strings; ---- [42, NULL, 84, NULL, 100] + +# Issue #10140 (used to crash) +statement error +SELECT DISTINCT OPERATOR ( / ) + ARRAY [ ] :: INTERVAL SECONDS [ ] [ ] :: SETOF NCHAR ARRAY :: FLOAT ; +---- +No function matches the given name and argument types