From 8a3eb1f06d1aabe8b44889e73a534ca37bcb61ba Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Mon, 1 Oct 2001 18:51:41 +0000 Subject: [PATCH] be-more-careful-about-references-when-adding-and-deleting-callbacks-20011001 perhaps too careful. to fix potential crash in TDel and TAdd ==================== This delta was composed from multiple commits as part of the CVS->Git migration. The checkin message with each commit was inconsistent. The following are the additional commit messages. ==================== remove extra ) which snuck in --- src/viced/callback.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/viced/callback.c b/src/viced/callback.c index 0d943aafd1..78ea701314 100644 --- a/src/viced/callback.c +++ b/src/viced/callback.c @@ -358,7 +358,12 @@ static TAdd(cb, thead) cb->tprev = thp->tprev; cb->tnext = *thead; - thp->tprev = (itocb(thp->tprev)->tnext = cbtoi(cb)); + if (thp) { + if (thp->tprev) + thp->tprev = (itocb(thp->tprev)->tnext = cbtoi(cb)); + else + thp->tprev = cbtoi(cb); + } } cb->thead = ttoi(thead); @@ -374,8 +379,10 @@ static TDel(cb) if (*thead == cbtoi(cb)) *thead = (*thead == cb->tnext? 0: cb->tnext); - itocb(cb->tprev)->tnext = cb->tnext; - itocb(cb->tnext)->tprev = cb->tprev; + if (itocb(cb->tprev)) + itocb(cb->tprev)->tnext = cb->tnext; + if (itocb(cb->tnext)) + itocb(cb->tnext)->tprev = cb->tprev; } /*TDel*/