[counters] Fix potential overflow in string sampling