journal: do not dereference already freed patterns
authorPhilippe De Swert <philippedeswert@gmail.com>
Wed, 10 Sep 2014 09:20:39 +0000 (12:20 +0300)
committerDavid Herrmann <dh.herrmann@gmail.com>
Thu, 11 Sep 2014 15:13:59 +0000 (17:13 +0200)
In case set_consume goes wrong, the pattern name has already been
freed. So we do not try to print it in the logs, assuming the pattern
addition print will be printed just before the failure anyway. Found
with coverity. Fixes: CID#1237798

src/journal/coredumpctl.c

index f5cf85a..34dcae8 100644 (file)
@@ -110,8 +110,7 @@ static int add_match(Set *set, const char *match) {
         log_debug("Adding pattern: %s", pattern);
         r = set_consume(set, pattern);
         if (r < 0) {
-                log_error("Failed to add pattern '%s': %s",
-                          pattern, strerror(-r));
+                log_error("Failed to add pattern: %s", strerror(-r));
                 goto fail;
         }