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:
parent
c72f3dc27e
commit
6f33f64ce5
2 changed files with 10 additions and 2 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue