addDirContents: Fix memory leak on error

In addDirContents, we would iterate through the directory entries,
freeing each one after we had processed it. However, if an error
occurred while scanning a child directory, we would exit the loop early.
This would result in the current and later entries not being freed.

Now, we free the entry list *after* we have finished processing it,
regardless of whether or not an error occurred. This guarantees that the
memory allocated by PlatformReadDir is always freed.