Repository: duckdb/duckdb (language: python)

Issue:
INTERNAL Error: Attempted to access index 0 within vector of size 0
### What happens?

The below test case caused an internal error.

### To Reproduce

```sql
CREATE TABLE  t1(c1 INT );

SELECT * FROM t1 ORDER BY LIST_ZIP(FALSE);

-- INTERNAL Error:
-- Attempted to access index 0 within vector of size 0
```

### OS:

Ubuntu 22.04

### DuckDB Version:

v1.1.4-dev2283 44c3e83b29

### DuckDB Client:

CLI

### Hardware:

_No response_

### Full Name:

Suyang Zhong

### Affiliation:

NUS

### What is the latest build you tested with? If possible, we recommend testing with the latest nightly build.

I have tested with a source build

### Did you include all relevant data sets for reproducing the issue?

Yes

### Did you include all code required to reproduce the issue?

- [X] Yes, I have

### Did you include all relevant configuration (e.g., CPU architecture, Python version, Linux distribution) to reproduce the issue?

- [X] Yes, I have


Discussion / hints:

Fix patch:
diff --git a/src/function/scalar/list/list_zip.cpp b/src/function/scalar/list/list_zip.cpp
index 106e72ff2b28..ef39a989d67d 100644
--- a/src/function/scalar/list/list_zip.cpp
+++ b/src/function/scalar/list/list_zip.cpp
@@ -132,7 +132,9 @@ static unique_ptr<FunctionData> ListZipBind(ClientContext &context, ScalarFuncti
 		throw BinderException("Provide at least one argument to " + bound_function.name);
 	}
 	if (arguments[size - 1]->return_type.id() == LogicalTypeId::BOOLEAN) {
-		size--;
+		if (--size == 0) {
+			throw BinderException("Provide at least one list argument to " + bound_function.name);
+		}
 	}
 
 	case_insensitive_set_t struct_names;


Test patch:
diff --git a/test/sql/function/list/list_zip.test b/test/sql/function/list/list_zip.test
index 243b14b1df26..52f3810e0a38 100644
--- a/test/sql/function/list/list_zip.test
+++ b/test/sql/function/list/list_zip.test
@@ -315,3 +315,12 @@ SELECT list_zip('')
 statement error
 SELECT list_zip(3, 4)
 ----
+
+statement error
+SELECT list_zip(FALSE)
+----
+
+statement error
+SELECT list_zip(TRUE)
+----
+