public inbox for dwz@sourceware.org
 help / color / mirror / Atom feed
From: Tom de Vries <tdevries@suse.de>
To: dwz@sourceware.org, jakub@redhat.com, mark@klomp.org
Subject: [committed] Initialize pids in dwz_files_1
Date: Sat, 27 Mar 2021 13:56:43 +0100	[thread overview]
Message-ID: <20210327125641.GA18300@delia> (raw)

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);

                 reply	other threads:[~2021-03-27 12:56 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210327125641.GA18300@delia \
    --to=tdevries@suse.de \
    --cc=dwz@sourceware.org \
    --cc=jakub@redhat.com \
    --cc=mark@klomp.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).