public inbox for dwz@sourceware.org
 help / color / mirror / Atom feed
* [committed] Initialize pids in dwz_files_1
@ 2021-03-27 12:56 Tom de Vries
  0 siblings, 0 replies; only message in thread
From: Tom de Vries @ 2021-03-27 12:56 UTC (permalink / raw)
  To: dwz, jakub, mark

Hi,

The loop dealing with waiting on the remaining children contains:
...
         if (res->res == -2)
           /* Skip hard links.  */
           continue;
...

The reason we need this is because the pids array isn't initialized in this
case, so the following code:
...
          if (pids[i] == 0)
            continue;
...
would otherwise read an uninitialized variable.

Fix this by:
- initializing the pids array, and
- removing the res->res == -2 code.

Committed to trunk.

Thanks,
- Tom

Initialize pids in dwz_files_1

2021-03-27  Tom de Vries  <tdevries@suse.de>

	* dwz.c (dwz_files_1): Initialize pids.  Simplify loop waiting on
	remaining children.

---
 dwz.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/dwz.c b/dwz.c
index bd40e90..3e7eb24 100644
--- a/dwz.c
+++ b/dwz.c
@@ -16496,6 +16496,8 @@ dwz_files_1 (int nr_files, char *files[], bool hardlink,
   if (max_forks > 1 && multifile == NULL)
     {
       pid_t pids[nr_files];
+      for (i = 0; i < nr_files; i++)
+	pids[i] = 0;
       for (i = 0; i < nr_files; i++)
 	{
 	  int thisret;
@@ -16529,11 +16531,7 @@ dwz_files_1 (int nr_files, char *files[], bool hardlink,
       for (i = 0; i < nr_files; i++)
 	{
 	  int thisret;
-	  file = files[i];
 	  struct file_result *res = &resa[i];
-	  if (res->res == -2)
-	    /* Skip hard links.  */
-	    continue;
 	  if (pids[i] == 0)
 	    continue;
 	  thisret = wait_child_exit (pids[i], &pids[i], 1, res);

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-03-27 12:56 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-27 12:56 [committed] Initialize pids in dwz_files_1 Tom de Vries

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).