In moving this out of the loop, you've arranged that CF_NULL only gets discarded when it's the sole entry in the list, where the code would previously discard any uses of it that showed up in an otherwise non-empty list (or, indeed, in a list with several CF_NULL and nothing else in it).  Are you sure this is harmless ?  (Seems likely ...)