Bläddra i källkod

libdpkg: Properly restore errno in push_cleanup

The code was saving errno for latter use, but stomping on the saved
value by assigning again errno to it. Invert the assignment so that
we restore errno instead of losing it.
Guillem Jover 16 år sedan
förälder
incheckning
3ce8687ba6
1 ändrade filer med 5 tillägg och 2 borttagningar
  1. 5 2
      lib/dpkg/ehandle.c

+ 5 - 2
lib/dpkg/ehandle.c

@@ -200,7 +200,7 @@ void push_cleanup(void (*call1)(int argc, void **argv), int mask1,
                   unsigned int nargs, ...) {
                   unsigned int nargs, ...) {
   struct cleanupentry *cep;
   struct cleanupentry *cep;
   void **argv;
   void **argv;
-  int e;
+  int e = 0;
   va_list args;
   va_list args;
 
 
   onerr_abort++;
   onerr_abort++;
@@ -222,7 +222,10 @@ void push_cleanup(void (*call1)(int argc, void **argv), int mask1,
   va_end(args);
   va_end(args);
   cep->next= econtext->cleanups;
   cep->next= econtext->cleanups;
   econtext->cleanups= cep;
   econtext->cleanups= cep;
-  if (cep == &emergency.ce) { e= errno; ohshite(_("out of memory for new cleanup entry")); }
+  if (cep == &emergency.ce) {
+    errno = e;
+    ohshite(_("out of memory for new cleanup entry"));
+  }
 
 
   onerr_abort--;
   onerr_abort--;
 }
 }