mirror of
https://github.com/NixOS/nix.git
synced 2025-11-28 21:21: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:
parent
c72f3dc27e
commit
6f33f64ce5
2 changed files with 10 additions and 2 deletions
|
|
@ -215,7 +215,11 @@ void nix_derivation_free(nix_derivation * drv)
|
||||||
|
|
||||||
StorePath * nix_store_path_clone(const StorePath * p)
|
StorePath * nix_store_path_clone(const StorePath * p)
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
return new StorePath{p->path};
|
return new StorePath{p->path};
|
||||||
|
} catch (...) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nix_derivation * nix_derivation_from_json(nix_c_context * context, Store * store, const char * json)
|
nix_derivation * nix_derivation_from_json(nix_c_context * context, Store * store, const char * json)
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,11 @@ extern "C" {
|
||||||
|
|
||||||
nix_c_context * nix_c_context_create()
|
nix_c_context * nix_c_context_create()
|
||||||
{
|
{
|
||||||
|
try {
|
||||||
return new nix_c_context();
|
return new nix_c_context();
|
||||||
|
} catch (...) {
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void nix_c_context_free(nix_c_context * context)
|
void nix_c_context_free(nix_c_context * context)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue