chiark / gitweb /
always use the same code for creating temporary files
[elogind.git] / src / journal / coredumpctl.c
index 2b24ff8a94f579d09a6f9323f9e9cff62e989874..3bceb48ff731351afb2dff3c9d9d675ad4da44e6 100644 (file)
@@ -126,10 +126,11 @@ static int add_match(Set *set, const char *match) {
                 goto fail;
 
         log_debug("Adding pattern: %s", pattern);
-        r = set_consume(set, pattern);
+        r = set_put(set, pattern);
         if (r < 0) {
                 log_error("Failed to add pattern '%s': %s",
                           pattern, strerror(-r));
+                free(pattern);
                 goto fail;
         }
 
@@ -416,7 +417,7 @@ static int dump_core(sd_journal* j) {
 
         r = sd_journal_previous(j);
         if (r >= 0)
-                log_warning("More than one entry matches, ignoring rest.\n");
+                log_warning("More than one entry matches, ignoring rest.");
 
         return 0;
 }
@@ -471,7 +472,7 @@ static int run_gdb(sd_journal *j) {
         data = (const uint8_t*) data + 9;
         len -= 9;
 
-        fd = mkostemp(path, O_WRONLY);
+        fd = mkostemp_safe(path, O_WRONLY|O_CLOEXEC);
         if (fd < 0) {
                 log_error("Failed to create temporary file: %m");
                 return -errno;