|
|
594167 |
From 97c96647418ffbadf3d964d76a5f54a9c54535c1 Mon Sep 17 00:00:00 2001
|
|
|
594167 |
From: Yu Watanabe <watanabe.yu+github@gmail.com>
|
|
|
594167 |
Date: Tue, 14 Jun 2022 09:04:00 +0900
|
|
|
594167 |
Subject: [PATCH] locale-util: fix memleak on failure
|
|
|
594167 |
|
|
|
594167 |
(cherry picked from commit 065058e63b566e21af737150ecd12bff57b97124)
|
|
|
594167 |
|
|
|
594167 |
Related: #2087652
|
|
|
594167 |
---
|
|
|
594167 |
src/basic/locale-util.c | 7 +++++--
|
|
|
594167 |
1 file changed, 5 insertions(+), 2 deletions(-)
|
|
|
594167 |
|
|
|
594167 |
diff --git a/src/basic/locale-util.c b/src/basic/locale-util.c
|
|
|
594167 |
index 7f1a2f15f7..abbebc7666 100644
|
|
|
594167 |
--- a/src/basic/locale-util.c
|
|
|
594167 |
+++ b/src/basic/locale-util.c
|
|
|
594167 |
@@ -156,7 +156,7 @@ static int add_locales_from_archive(Set *locales) {
|
|
|
594167 |
return r;
|
|
|
594167 |
}
|
|
|
594167 |
|
|
|
594167 |
-static int add_locales_from_libdir (Set *locales) {
|
|
|
594167 |
+static int add_locales_from_libdir(Set *locales) {
|
|
|
594167 |
_cleanup_closedir_ DIR *dir = NULL;
|
|
|
594167 |
int r;
|
|
|
594167 |
|
|
|
594167 |
@@ -183,7 +183,7 @@ static int add_locales_from_libdir (Set *locales) {
|
|
|
594167 |
}
|
|
|
594167 |
|
|
|
594167 |
int get_locales(char ***ret) {
|
|
|
594167 |
- _cleanup_set_free_ Set *locales = NULL;
|
|
|
594167 |
+ _cleanup_set_free_free_ Set *locales = NULL;
|
|
|
594167 |
_cleanup_strv_free_ char **l = NULL;
|
|
|
594167 |
int r;
|
|
|
594167 |
|
|
|
594167 |
@@ -203,6 +203,9 @@ int get_locales(char ***ret) {
|
|
|
594167 |
if (!l)
|
|
|
594167 |
return -ENOMEM;
|
|
|
594167 |
|
|
|
594167 |
+ /* Now, all elements are owned by strv 'l'. Hence, do not call set_free_free(). */
|
|
|
594167 |
+ locales = set_free(locales);
|
|
|
594167 |
+
|
|
|
594167 |
r = getenv_bool("SYSTEMD_LIST_NON_UTF8_LOCALES");
|
|
|
594167 |
if (r == -ENXIO || r == 0) {
|
|
|
594167 |
char **a, **b;
|