From: John Darrington Date: Mon, 24 Dec 2007 03:54:38 +0000 (+0000) Subject: Ignore null pointer in taint_destroy. Closes bug #21863 X-Git-Tag: v0.6.0~151 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f662ba6c542ef66d8ab80cb0a4154ff853cfc0af;p=pspp-builds.git Ignore null pointer in taint_destroy. Closes bug #21863 --- diff --git a/src/libpspp/ChangeLog b/src/libpspp/ChangeLog index 12c70f9d..502b9292 100644 --- a/src/libpspp/ChangeLog +++ b/src/libpspp/ChangeLog @@ -1,3 +1,7 @@ +2007-12-24 John Darrington + + * taint.c (taint_destroy): Return true if pointer is null. + 2007-11-25 Ben Pfaff * float-format.c (assemble_number): Only store 32 bits for Z short diff --git a/src/libpspp/taint.c b/src/libpspp/taint.c index 0c4194d5..3a74587b 100644 --- a/src/libpspp/taint.c +++ b/src/libpspp/taint.c @@ -95,26 +95,31 @@ taint_clone (const struct taint *taint_) bool taint_destroy (struct taint *taint) { - bool was_tainted = taint_is_tainted (taint); - if (--taint->ref_cnt == 0) + if ( taint ) { - size_t i, j; - - for (i = 0; i < taint->predecessors.cnt; i++) - for (j = 0; j < taint->successors.cnt; j++) - taint_propagate (taint->predecessors.taints[i], - taint->successors.taints[j]); - - for (i = 0; i < taint->predecessors.cnt; i++) - taint_list_remove (&taint->predecessors.taints[i]->successors, taint); - for (i = 0; i < taint->successors.cnt; i++) - taint_list_remove (&taint->successors.taints[i]->predecessors, taint); - - taint_list_destroy (&taint->successors); - taint_list_destroy (&taint->predecessors); - free (taint); + bool was_tainted = taint_is_tainted (taint); + if (--taint->ref_cnt == 0) + { + size_t i, j; + + for (i = 0; i < taint->predecessors.cnt; i++) + for (j = 0; j < taint->successors.cnt; j++) + taint_propagate (taint->predecessors.taints[i], + taint->successors.taints[j]); + + for (i = 0; i < taint->predecessors.cnt; i++) + taint_list_remove (&taint->predecessors.taints[i]->successors, taint); + for (i = 0; i < taint->successors.cnt; i++) + taint_list_remove (&taint->successors.taints[i]->predecessors, taint); + + taint_list_destroy (&taint->successors); + taint_list_destroy (&taint->predecessors); + free (taint); + } + return !was_tainted; } - return !was_tainted; + + return true; } /* Adds a propagation relationship from FROM to TO. This means