Fix a crash in DeleteTexture by handling cases where the head or tail (or both) of the linked list is being deleted.