Skip to content

Commit 22fc369

Browse files
Fix segfault
1 parent 8999c54 commit 22fc369

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/qtensornetwork.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,13 +303,13 @@ bool QTensorNetwork::ForceM(bitLenInt qubit, bool result, bool doForce, bool doA
303303
const size_t layerIdMin1 = layerId - 1U;
304304
std::map<bitLenInt, bool>& mMin1 = measurements[layerIdMin1];
305305
for (const auto& b : m) {
306-
auto it = mMin1.find(b.first);
306+
const auto it = mMin1.find(b.first);
307307
if ((it != mMin1.end()) && (it->second != b.second)) {
308308
// If the last measurement and this measurement do not agree, insert an X gate between.
309309
circuit[layerIdMin1]->AppendGate(std::make_shared<QCircuitGate>(b.first, pauliX));
310310
}
311311
// Collapse the measurements into the previous layer.
312-
it->second = b.second;
312+
mMin1[b.first] = b.second;
313313
}
314314
// Combine any remaining gates into the previous layer
315315
circuit[layerIdMin1]->Combine(circuit[layerId]);

0 commit comments

Comments
 (0)