From 886f288db1a71dd3fb2b9c07e5f16a8f3bca523c Mon Sep 17 00:00:00 2001 From: Luca Boccassi Date: Fri, 17 Oct 2025 10:23:28 +0100 Subject: [PATCH] efivars: fix potential memory leak If 'ret' is not passed, 'x' is leaked Follow-up for c8d60ae79d1763c6ef16fdb306b65d909a769de8 CID#1621673 (cherry picked from commit 05d45875f74cfb7455d127a5229dca440986e689) --- src/basic/efivars.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/basic/efivars.c b/src/basic/efivars.c index 8185a111d16..252b9d3451f 100644 --- a/src/basic/efivars.c +++ b/src/basic/efivars.c @@ -164,9 +164,8 @@ int efi_get_variable( } int efi_get_variable_string(const char *variable, char **ret) { - _cleanup_free_ void *s = NULL; + _cleanup_free_ void *s = NULL, *x = NULL; size_t ss = 0; - char *x; int r; assert(variable); @@ -180,7 +179,7 @@ int efi_get_variable_string(const char *variable, char **ret) { return -ENOMEM; if (ret) - *ret = x; + *ret = TAKE_PTR(x); return 0; } -- 2.47.3