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);
}
}
if (head==NULL)
return NULL;
- /* will not remove the head here, that has already been done */
- for (idp=head; idp->next!=NULL; idp=idp->next) {
+ /* Will not remove the head here, that has already been done.*/
+ for (idp=head; (idp!=NULL) && (idp->next!=NULL); idp=idp->next) {
if (idp->next->refcount==0) {
old_next=idp->next;
- tr_idp_realm_remove(head, idp->next); /* changes idp->next */
+ tr_idp_realm_remove(head, idp->next); /* changes idp->next, may make it NULL */
tr_idp_realm_free(old_next);
}
}
return NULL;
/* will not remove the head here, that has already been done */
- for (rp=head; rp->next!=NULL; rp=rp->next) {
+ for (rp=head; (rp!=NULL) && (rp->next!=NULL); rp=rp->next) {
if (rp->next->refcount==0) {
old_next=rp->next;
- tr_rp_realm_remove(head, rp->next); /* changes rp->next */
+ tr_rp_realm_remove(head, rp->next); /* changes rp->next, may make it null */
tr_rp_realm_free(old_next);
}
}