I've come across a case where dep == NULL causing crash. Probably this call needs to be guarded by if (dep)...