SDAG case: don't leak when triggers that are cancelled
authorPhil Miller <mille121@illinois.edu>
Mon, 22 Oct 2012 04:59:14 +0000 (23:59 -0500)
committerPhil Miller <mille121@illinois.edu>
Mon, 22 Oct 2012 04:59:14 +0000 (23:59 -0500)
src/ck-core/sdag.h

index cf6b75f077461a2a4db6a7ec586d2ad2cd005048..2b90ee48436b3bc92c8b9a81add34358d10747b1 100644 (file)
@@ -460,10 +460,15 @@ class CDep {
    void removeAllSpeculationIndex(int speculationIndex) {
      for (int i = 0; i < numWhens; i++) {
        TListCWhenTrigger *wlist = whens[i];
    void removeAllSpeculationIndex(int speculationIndex) {
      for (int i = 0; i < numWhens; i++) {
        TListCWhenTrigger *wlist = whens[i];
-       for (CWhenTrigger *elem = wlist->begin(); !wlist->end(); elem = wlist->next()) {
-         if (elem == 0) break;
+       CWhenTrigger *elem = wlist->begin();
+       while (elem && !wlist->end()) {
          if (elem->speculationIndex == speculationIndex) {
          if (elem->speculationIndex == speculationIndex) {
-           elem = deRegister(elem);
+           CWhenTrigger *cancelled = elem;
+           deRegister(elem);
+           elem = wlist->next();
+           delete cancelled;
+         } else {
+           elem = wlist->next();
          }
        }
      }
          }
        }
      }