]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
conf-parser: fix memleak in config_parse_calendar()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Tue, 27 Aug 2024 02:17:56 +0000 (11:17 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 1 Sep 2024 20:41:55 +0000 (05:41 +0900)
Fixes a bug introduced by 0e10c3d8724b0a5d07871c9de71565ac91dd55b7 (#25049).

src/shared/conf-parser.c

index c4633fc52f1e969d4ca6d021dd88795f4e89a2ab..978a477f6dd7356445e9bd9725654b1320eae835 100644 (file)
@@ -2038,11 +2038,12 @@ int config_parse_calendar(
         }
 
         r = calendar_spec_from_string(rvalue, &c);
-        if (r < 0)
+        if (r < 0) {
                 log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to parse calendar specification, ignoring: %s", rvalue);
-        else
-                *cr = TAKE_PTR(c);
+                return 0;
+        }
 
+        free_and_replace_full(*cr, c, calendar_spec_free);
         return 0;
 }