chiark / gitweb /
coredumpctl: fix potential deref of null pointer
[elogind.git] / src / journal / coredump.c
index 5e93091f8bd1bedd2f26357cbd331098a4b2fa63..ab8fd2cf0e9acaca372e644d5b779c90fa0953e7 100644 (file)
@@ -345,16 +345,16 @@ static int save_external_coredump(const char *info[_INFO_LEN],
                 goto fail;
         }
 
-        if (lseek(fd, 0, SEEK_SET) == (off_t) -1) {
-                log_error("Failed to seek on %s: %m", tmp);
-                goto uncompressed;
-        }
-
         if (fstat(fd, &st) < 0) {
                 log_error("Failed to fstat coredump %s: %m", tmp);
                 goto fail;
         }
 
+        if (lseek(fd, 0, SEEK_SET) == (off_t) -1) {
+                log_error("Failed to seek on %s: %m", tmp);
+                goto uncompressed;
+        }
+
 #ifdef HAVE_XZ
         /* If we will remove the coredump anyway, do not compress. */
         if (maybe_remove_external_coredump(NULL, st.st_size) == 0