X-Git-Url: http://www.project-moonshot.org/gitweb/?a=blobdiff_plain;f=common%2Ftr_comm.c;h=dd3c304d4d9783c3e33bbc8e59759c610d4de758;hb=3485c59e1faa3df7df6064059388e6502d4c77c8;hp=6212b5dd68b5351ed4bfa880f9be2e0143c11790;hpb=3d5b32212a270065a09f6c605ec0632275ed5b86;p=trust_router.git diff --git a/common/tr_comm.c b/common/tr_comm.c index 6212b5d..dd3c304 100644 --- a/common/tr_comm.c +++ b/common/tr_comm.c @@ -372,10 +372,10 @@ static TR_COMM *tr_comm_sweep_func(TR_COMM *head) return NULL; /* will not remove the head here, that has already been done */ - for (comm=head; comm->next!=NULL; comm=comm->next) { + for (comm=head; (comm!=NULL) && (comm->next!=NULL); comm=comm->next) { if (comm->next->refcount==0) { old_next=comm->next; - tr_comm_remove(head, comm->next); /* changes comm->next */ + tr_comm_remove(head, comm->next); /* changes comm->next, may make it null */ tr_comm_free(old_next); } }