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