OSSP CVS Repository

ossp - Check-in [3133]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 3133
Date: 2003-Jan-31 19:58:18 (local)
2003-Jan-31 18:58:18 (UTC)
User:rse
Branch:
Comment: Fixed test suite library (ts.c): the ts_suite_free() function performed an illegal iteration for freeing elements (they were freed but still references for traversing to next element). This is now solved by a look-ahead traversion.

Hint by: Brian T. Egleston <brian@egleston.com>

Tickets:
Inspections:
Files:
ossp-pkg/sa/ChangeLog      1.22 -> 1.23     6 inserted, 0 deleted
ossp-pkg/sa/ts.c      1.6 -> 1.7     10 inserted, 6 deleted

ossp-pkg/sa/ChangeLog 1.22 -> 1.23

--- ChangeLog    2003/01/31 18:34:06     1.22
+++ ChangeLog    2003/01/31 18:58:18     1.23
@@ -13,6 +13,12 @@
 
   Changes between 1.0.4 and 1.0.5 (28-Jan-2003 to 31-Jan-2003)
 
+   o Fixed test suite library (ts.c): the ts_suite_free()
+     function performed an illegal iteration for freeing elements (they
+     were freed but still references for traversing to next element).
+     This is now solved by a look-ahead traversion.
+     [Ralf S. Engelschall, Brian T. Egleston <brian@egleston.com>]
+
    o Fixed test suite (sa_test.c): an sa_addr_t was destroyed
      too early and this way crashed the test suite.
      [Brian T. Egleston <brian@egleston.com>]


ossp-pkg/sa/ts.c 1.6 -> 1.7

--- ts.c 2002/11/07 12:44:12     1.6
+++ ts.c 2003/01/31 18:58:18     1.7
@@ -76,6 +76,10 @@
     for ((ep)  = RING_FIRST((hp)); \
          (ep) != RING_SENTINEL((hp), elem, link); \
          (ep)  = RING_NEXT((ep), link))
+#define RING_FOREACH_LA(ep, epT, hp, elem, link) \
+    for ((ep)  = RING_FIRST((hp)), (epT) = RING_NEXT((ep), link); \
+         (ep) != RING_SENTINEL((hp), elem, link); \
+         (ep)  = (epT), (epT) = RING_NEXT((epT), link))
 
 /* test suite test log */
 struct tstl_st;
@@ -367,15 +371,15 @@
 /* destroy test suite */
 void ts_suite_free(ts_suite_t *ts)
 {
-    ts_test_t *tst;
-    tstc_t *tstc;
-    tstl_t *tstl;
+    ts_test_t *tst, *tstT;
+    tstc_t *tstc, *tstcT;
+    tstl_t *tstl, *tstlT;
 
     if (ts == NULL)
         return;
-    RING_FOREACH(tst, &ts->tests, ts_test_t, next) {
-        RING_FOREACH(tstc, &tst->checks, tstc_t, next) {
-            RING_FOREACH(tstl, &tstc->logs, tstl_t, next) {
+    RING_FOREACH_LA(tst, tstT, &ts->tests, ts_test_t, next) {
+        RING_FOREACH_LA(tstc, tstcT, &tst->checks, tstc_t, next) {
+            RING_FOREACH_LA(tstl, tstlT, &tstc->logs, tstl_t, next) {
                 free(tstl->text);
             }
             free(tstc->title);

CVSTrac 2.0.1