void-packages/srcpkgs/qucs/patches/qucsator-fix-list-traversion.patch
Martijn van Buul bcd147c5e1 qucs: Fix simulator crash
Avoid undefined behaviour while traversing and modifying a std::list.
Patch has been reported to Qucs upstream.

Fixes https://github.com/voidlinux/void-packages/issues/7604
2017-09-14 21:32:38 +02:00

17 lines
656 B
Diff

--- qucs-core/src/net.cpp.org 2017-09-13 20:47:24.863069583 +0200
+++ qucs-core/src/net.cpp 2017-09-10 00:16:48.863636748 +0200
@@ -350,7 +350,13 @@
void net::sortChildAnalyses (analysis * parent) {
ptrlist<analysis> * alist = parent->getAnalysis ();
if (alist != nullptr) {
- for (auto *a: *alist) {
+
+ for (auto it = alist->begin(); it != alist->end(); /* empty */) {
+ // Copy the value of the element (a pointer), and advance the
+ // iterator prior to manipulating the list.
+ analysis *a = *it;
+ ++it;
+
if (a->getType () == ANALYSIS_DC
|| containsAnalysis (a, ANALYSIS_DC)) {
parent->delAnalysis (a);