--- sed-4.1.orig/sed/execute.c
+++ sed-4.1/sed/execute.c
@@ -670,6 +670,8 @@
       output_file.fp = ck_mkstemp (&input->out_file_name, tmpdir, "sed");
       free (tmpdir);
 
+      output_fd = fileno(output_file.fp);
+
       fstat (fileno (input->fp), &st);
 #ifdef HAVE_FCHMOD
       fchmod (output_fd, st.st_mode);