Просмотр исходного кода

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

This makes the code more clear, and should unconfuse the clang static
analyzer.
Guillem Jover лет назад: 12
Родитель
Сommit
9431994c82
1 измененных файлов с 3 добавлено и 2 удалено
  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++) {
     for (i=0; i<cdn; i++) {
       strcpy(updatefnrest, cdlist[i]->d_name);
       strcpy(updatefnrest, cdlist[i]->d_name);
       parsedb(updatefnbuf, pdb_parse_update, NULL);
       parsedb(updatefnbuf, pdb_parse_update, NULL);
-      if (cstatus < msdbrw_write) free(cdlist[i]);
     }
     }
 
 
     if (cstatus >= msdbrw_write) {
     if (cstatus >= msdbrw_write) {
@@ -99,11 +98,13 @@ static void cleanupdates(void) {
         strcpy(updatefnrest, cdlist[i]->d_name);
         strcpy(updatefnrest, cdlist[i]->d_name);
         if (unlink(updatefnbuf))
         if (unlink(updatefnbuf))
           ohshite(_("failed to remove incorporated update file %.255s"),updatefnbuf);
           ohshite(_("failed to remove incorporated update file %.255s"),updatefnbuf);
-        free(cdlist[i]);
       }
       }
 
 
       dir_sync_path(updatesdir);
       dir_sync_path(updatesdir);
     }
     }
+
+    for (i = 0; i < cdn; i++)
+      free(cdlist[i]);
   }
   }
   free(cdlist);
   free(cdlist);