1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-30 14:10:59 +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

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