Skip to content

Conversation

jraymakers
Copy link
Contributor

@jraymakers jraymakers commented Mar 2, 2025

While working on exposing the instance cache through Node Neo using the C API, I found that passing nullptr to the path argument of duckdb_get_or_create_from_cache resulted in a seg fault. Note that duckdb_open accepts nullptr just fine. Both functions are documented to accept nullptr.

This occurred because the C++ API takes a duckdb::string, which can't contain nullptr, but the C API was passing in a const char * that could be nullptr. The simple fix is to check for nullptr in this case and pass an empty string instead.

I added a few basic tests of this function for various special values of the path argument: nullptr, empty string, and ":memory:". The nullptr test case fails without this fix; the other two are fine.

Note that I'm submitting this PR to the v1.2-histrionicus branch in the hopes it can get in before the release of 1.2.1 this week.

@Mytherin Mytherin merged commit a0b525c into duckdb:v1.2-histrionicus Mar 3, 2025
47 of 48 checks passed
@Mytherin
Copy link
Collaborator

Mytherin commented Mar 3, 2025

Thanks!

krlmlr added a commit to duckdb/duckdb-r that referenced this pull request Mar 7, 2025
fix passing a null path to the C API instance cache (duckdb/duckdb#16474)
[Python Dev] Make `pandas` not required in a couple places, check if it's installed in others (duckdb/duckdb#16414)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants