mirror of
https://github.com/morgan9e/systemd
synced 2026-04-14 00:14:32 +09:00
efivars: fix potential memory leak
If 'ret' is not passed, 'x' is leaked
Follow-up for c8d60ae79d
CID#1621673
This commit is contained in:
@@ -155,9 +155,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);
|
||||
@@ -171,7 +170,7 @@ int efi_get_variable_string(const char *variable, char **ret) {
|
||||
return -ENOMEM;
|
||||
|
||||
if (ret)
|
||||
*ret = x;
|
||||
*ret = TAKE_PTR(x);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user