Patchwork D7558: fuzz: fix an unused result on getcwd() in pyutil

login
register
mail settings
Submitter phabricator
Date Dec. 7, 2019, 3:59 a.m.
Message ID <cbda94993791d31eb4af0b2eb061ad5f@localhost.localdomain>
Download mbox | patch
Permalink /patch/43619/
State Not Applicable
Headers show

Comments

phabricator - Dec. 7, 2019, 3:59 a.m.
Closed by commit rHGf6c0b0510b49: fuzz: fix an unused result on getcwd() in pyutil (authored by durin42).
This revision was automatically updated to reflect the committed changes.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D7558?vs=18496&id=18509

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D7558/new/

REVISION DETAIL
  https://phab.mercurial-scm.org/D7558

AFFECTED FILES
  contrib/fuzz/pyutil.cc

CHANGE DETAILS




To: durin42, #hg-reviewers, indygreg
Cc: mercurial-devel

Patch

diff --git a/contrib/fuzz/pyutil.cc b/contrib/fuzz/pyutil.cc
--- a/contrib/fuzz/pyutil.cc
+++ b/contrib/fuzz/pyutil.cc
@@ -1,5 +1,6 @@ 
 #include "pyutil.h"
 
+#include <iostream>
 #include <string>
 
 namespace contrib
@@ -24,7 +25,11 @@ 
 	auto pos = selfpath.rfind("/");
 	if (pos == std::string::npos) {
 		char wd[8192];
-		getcwd(wd, 8192);
+		if (!getcwd(wd, 8192)) {
+			std::cerr << "Failed to call getcwd: errno " << errno
+			          << std::endl;
+			exit(1);
+		}
 		pypath = std::string(wd) + subdir;
 	} else {
 		pypath = selfpath.substr(0, pos) + subdir;