]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
sleep-config: fix potential memory leak
authorMike Yuan <me@yhndnzj.com>
Wed, 27 Mar 2024 13:03:30 +0000 (21:03 +0800)
committerMike Yuan <me@yhndnzj.com>
Thu, 28 Mar 2024 09:16:24 +0000 (17:16 +0800)
Follow-up for 77bd39385eae7b8e3182e66292b9f94bb54e235d

src/shared/sleep-config.c

index 5f51ab45dea6b89f13162731a7830c2be142be9b..f99c38bc79aedc262a5457e16ac93cfcc8383d30 100644 (file)
@@ -69,8 +69,8 @@ static int config_parse_sleep_mode(
                 void *data,
                 void *userdata) {
 
-        _cleanup_strv_free_ char **modes = NULL;
         char ***sv = ASSERT_PTR(data);
+        _cleanup_strv_free_ char **modes = NULL;
         int r;
 
         assert(filename);
@@ -87,7 +87,7 @@ static int config_parse_sleep_mode(
                         return log_oom();
         }
 
-        return free_and_replace(*sv, modes);
+        return strv_free_and_replace(*sv, modes);
 }
 
 static void sleep_config_validate_state_and_mode(SleepConfig *sc) {