Fix a memory leak in xmldoc