1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-28 13:11:00 +01:00

C API: Need to try-catch around new

Per https://en.cppreference.com/w/cpp/memory/new/operator_new.html, it
can throw if the allocation fails.
This commit is contained in:
John Ericson 2025-11-24 18:25:43 -05:00
parent c72f3dc27e
commit 6f33f64ce5
2 changed files with 10 additions and 2 deletions

View file

@ -215,7 +215,11 @@ void nix_derivation_free(nix_derivation * drv)
StorePath * nix_store_path_clone(const StorePath * p)
{
try {
return new StorePath{p->path};
} catch (...) {
return nullptr;
}
}
nix_derivation * nix_derivation_from_json(nix_c_context * context, Store * store, const char * json)

View file

@ -13,7 +13,11 @@ extern "C" {
nix_c_context * nix_c_context_create()
{
try {
return new nix_c_context();
} catch (...) {
return nullptr;
}
}
void nix_c_context_free(nix_c_context * context)