Make code more error resilient when parsing data files.
authorMilian Wolff <mail@milianw.de>
Thu, 24 Mar 2016 21:34:08 +0000 (22:34 +0100)
committerMilian Wolff <mail@milianw.de>
Thu, 24 Mar 2016 21:34:08 +0000 (22:34 +0100)
accumulatedtracedata.cpp

index 485d704..c0f455a 100644 (file)
@@ -365,8 +365,11 @@ Allocation& AccumulatedTraceData::findAllocation(const TraceIndex traceIndex)
                             [] (const Allocation& allocation, const TraceIndex traceIndex) -> bool {
                                 return allocation.traceIndex < traceIndex;
                             });
-        assert(it != allocations.end());
-        assert(it->traceIndex == traceIndex);
+        if (it == allocations.end() || it->traceIndex != traceIndex) {
+            Allocation allocation;
+            allocation.traceIndex = traceIndex;
+            it = allocations.insert(it, allocation);
+        }
         return *it;
     } else if (traceIndex == m_maxAllocationTraceIndex && !allocations.empty()) {
         // reuse the last allocation