1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-25 14:51:16 +02:00

C API: Make nix_err_msg treat NIX_OK as having no message

The documentation "solved" this by specifying a precondition, but
let's just make it more robust, and not leak irrelevant messages
that might linger.
We don't clear the message when clearing the status, in order to
keep clearing fast; see last_err field doc.
This commit is contained in:
Robert Hensing 2024-06-14 16:36:23 +02:00
parent 2dc7598779
commit 61381c9964
2 changed files with 2 additions and 1 deletions

View file

@ -112,7 +112,7 @@ const char * nix_err_msg(nix_c_context * context, const nix_c_context * read_con
{
if (context)
context->last_err_code = NIX_OK;
if (read_context->last_err) {
if (read_context->last_err && read_context->last_err_code != NIX_OK) {
if (n)
*n = read_context->last_err->size();
return read_context->last_err->c_str();