nfc_linux: Don't close stdin if fido_nl_new fails

The call to nfc_free is not needed because when calloc fails ctx will be
NULL and nfc_free will do nothing, when fido_nl_new() fails ctx->nl will
be null and does not need to be freed.
Additionally ctx->fd is 0 (due to calloc zero-initializing ctx) and
should not be closed.
Therefore I replaced this with a free call to just undo the (potential)
allocation by calloc.

Signed-off-by: Tobias Wiese <tobias@tobiaswiese.com>
This commit is contained in:
Tobias Wiese
2025-12-19 08:46:52 +01:00
committed by Ludvig Michaelsson
parent b23d41ba41
commit a94e52cb9e
+1 -1
View File
@@ -237,7 +237,7 @@ nfc_new(uint32_t dev)
if ((ctx = calloc(1, sizeof(*ctx))) == NULL ||
(ctx->nl = fido_nl_new()) == NULL) {
nfc_free(&ctx);
free(ctx);
return NULL;
}