1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-29 02:11:15 +02:00

C API: nix_store_open, check for empty strings

This commit is contained in:
José Luis Lafuente 2024-01-11 22:41:57 +01:00 committed by José Luis Lafuente
parent 535694122e
commit d5ec1d0617
No known key found for this signature in database
GPG key ID: 8A3455EBE455489A
2 changed files with 35 additions and 11 deletions

View file

@ -33,19 +33,19 @@ Store * nix_store_open(nix_c_context * context, const char * uri, const char ***
if (context)
context->last_err_code = NIX_OK;
try {
if (!uri) {
return new Store{nix::openStore()};
} else {
std::string uri_str = uri;
if (!params)
return new Store{nix::openStore(uri_str)};
std::string uri_str = uri ? uri : "";
nix::Store::Params params_map;
for (size_t i = 0; params[i] != nullptr; i++) {
params_map[params[i][0]] = params[i][1];
}
return new Store{nix::openStore(uri_str, params_map)};
if (uri_str.empty())
return new Store{nix::openStore()};
if (!params)
return new Store{nix::openStore(uri_str)};
nix::Store::Params params_map;
for (size_t i = 0; params[i] != nullptr; i++) {
params_map[params[i][0]] = params[i][1];
}
return new Store{nix::openStore(uri_str, params_map)};
}
NIXC_CATCH_ERRS_NULL
}