Bug 1418415 - Do more error checking. r=mccr8

While looking at this code I found a couple of places where errors could
get ignored or silently discarded and result in corrupt data. This
checks for the errors and fails harder.

Depends on D10353

Differential Revision: https://phabricator.services.mozilla.com/D10354

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Kartikaya Gupta 2018-10-31 20:45:13 +00:00
parent 160df1fcad
commit 86cb4f4e4d
2 changed files with 5 additions and 2 deletions

View File

@ -60,7 +60,9 @@ AutoLockFile::AutoLockFile(const std::string &Filename) {
return;
}
WaitForSingleObject(Handle, INFINITE);
if (WaitForSingleObject(Handle, INFINITE) != WAIT_OBJECT_0) {
return;
}
FileDescriptor = _open(Filename.c_str(), _O_RDWR | _O_CREAT | _O_BINARY, 0666);
}

View File

@ -479,7 +479,8 @@ public:
AutoLockFile Lock(Filename);
if (!Lock.success()) {
continue;
fprintf(stderr, "Unable to lock file %s\n", Filename.c_str());
exit(1);
}
std::vector<std::string> Lines;