When i.eof() or i.fail(), the allocated char[] was not deleted before the return. Thanks to clang-3.4 LeakSanitizer.