Selaa lähdekoodia

dpkg: Make fd variable passed to cu_closefd static

The push_cleanup() call takes a pointer to the fd variable which resides
in the stack. In case of error and stack unwinding due to longjmp, the
value of fd might get overwritten by subsequent stack usage. Thus this
kind of variables need to be static so that their value cannot change
on stack rollback.
Guillem Jover 15 vuotta sitten
vanhempi
commit
d6f176b4b8
1 muutettua tiedostoa jossa 1 lisäystä ja 1 poistoa
  1. 1 1
      src/filesdb.c

+ 1 - 1
src/filesdb.c

@@ -276,7 +276,7 @@ pkg_files_add_file(struct pkginfo *pkg, const char *filename,
 void
 ensure_packagefiles_available(struct pkginfo *pkg)
 {
-  int fd;
+  static int fd;
   const char *filelistfile;
   struct fileinlist **lendp;
   struct stat stat_buf;