corelib/counter: Correctly handle NULL case.