Prechádzať zdrojové kódy

libdpkg: Unify scandir() list element free()ing

This makes the code more clear, and should unconfuse the clang static
analyzer.
Guillem Jover 12 rokov pred
rodič
commit
9431994c82
1 zmenil súbory, kde vykonal 3 pridanie a 2 odobranie
  1. 3 2
      lib/dpkg/dbmodify.c

+ 3 - 2
lib/dpkg/dbmodify.c

@@ -89,7 +89,6 @@ static void cleanupdates(void) {
     for (i=0; i<cdn; i++) {
       strcpy(updatefnrest, cdlist[i]->d_name);
       parsedb(updatefnbuf, pdb_parse_update, NULL);
-      if (cstatus < msdbrw_write) free(cdlist[i]);
     }
 
     if (cstatus >= msdbrw_write) {
@@ -99,11 +98,13 @@ static void cleanupdates(void) {
         strcpy(updatefnrest, cdlist[i]->d_name);
         if (unlink(updatefnbuf))
           ohshite(_("failed to remove incorporated update file %.255s"),updatefnbuf);
-        free(cdlist[i]);
       }
 
       dir_sync_path(updatesdir);
     }
+
+    for (i = 0; i < cdn; i++)
+      free(cdlist[i]);
   }
   free(cdlist);