Fix division-by-zero crash

Not clear why step_->jobsets was empty...
This commit is contained in:
Eelco Dolstra 2015-10-30 18:01:48 +01:00
parent 1ff48da3d3
commit d8d188301d

View file

@ -136,11 +136,13 @@ bool State::doBuildStep(std::shared_ptr<StoreAPI> store, Step::ptr step,
among the jobsets that depend on it. */ among the jobsets that depend on it. */
{ {
auto step_(step->state.lock()); auto step_(step->state.lock());
if (!step_->jobsets.empty()) {
// FIXME: loss of precision. // FIXME: loss of precision.
time_t charge = (result.stopTime - result.startTime) / step_->jobsets.size(); time_t charge = (result.stopTime - result.startTime) / step_->jobsets.size();
for (auto & jobset : step_->jobsets) for (auto & jobset : step_->jobsets)
jobset->addStep(result.startTime, charge); jobset->addStep(result.startTime, charge);
} }
}
/* Asynchronously compress the log. */ /* Asynchronously compress the log. */
if (result.logFile != "") { if (result.logFile != "") {