Remove always-false check old == cur This case is already checked at the start of the function. There it returns NULL, which seems more correct.