From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx2.suse.de (mx2.suse.de [195.135.220.15]) by sourceware.org (Postfix) with ESMTPS id 6BC38385800F for ; Sat, 27 Mar 2021 12:56:45 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6BC38385800F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=tdevries@suse.de X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 85FF4AE05; Sat, 27 Mar 2021 12:56:44 +0000 (UTC) Date: Sat, 27 Mar 2021 13:56:43 +0100 From: Tom de Vries To: dwz@sourceware.org, jakub@redhat.com, mark@klomp.org Subject: [committed] Initialize pids in dwz_files_1 Message-ID: <20210327125641.GA18300@delia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) X-Spam-Status: No, score=-12.0 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, KAM_NUMSUBJECT, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: dwz@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Dwz mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Mar 2021 12:56:48 -0000 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 * 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);