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

Merge pull request #12620 from nix-windows/c-api/leaks

c-api: fix a few memory leaks
This commit is contained in:
Robert Hensing 2025-03-08 22:06:59 +01:00 committed by GitHub
commit a047dec120
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 9 additions and 1 deletions

View file

@ -199,7 +199,9 @@ EvalState * nix_state_create(nix_c_context * context, const char ** lookupPath_c
!= NIX_OK)
return nullptr;
return nix_eval_state_build(context, builder);
auto *state = nix_eval_state_build(context, builder);
nix_eval_state_builder_free(builder);
return state;
}
void nix_state_free(EvalState * state)

View file

@ -63,6 +63,9 @@ TEST_F(nix_api_expr_test, nix_expr_eval_external)
std::string string_value;
nix_get_string(nullptr, valueResult, OBSERVE_STRING(string_value));
ASSERT_STREQ("nix-external<MyExternalValueDesc( 42 )>", string_value.c_str());
nix_state_free(stateResult);
nix_state_free(stateFn);
}
}

View file

@ -43,6 +43,9 @@ TEST_F(nix_api_store_test, nix_api_init_global_getFlake_exists)
ASSERT_NE(nullptr, value);
nix_err err = nix_expr_eval_from_string(ctx, state, "builtins.getFlake", ".", value);
nix_state_free(state);
assert_ctx_ok();
ASSERT_EQ(NIX_OK, err);
ASSERT_EQ(NIX_TYPE_FUNCTION, nix_get_type(ctx, value));