There seems to be a minor bug in LazFileUtils, specifically in the
function ConvertUTF16ToUTF8(Dest: PChar; DestCharCount: SizeUInt;
Src: PWideChar; SrcWideCharCount: SizeUInt; Options: TConvertOptions;
out ActualCharCount: SizeUInt): TConvertResult;
althouugh I am not sure I have traced through the debugger correctly.
The function is very clever, and relies on casts of string to PChar, and also casts the
'th widechar to a Word value which is used in a comparison. Perhaps the output string is not finalised correctly?
I am not clever enough to see what is causing the leak, but ansistring/widestring conversion is a pretty specialist topic, and I am sure it requires an expert in cross-platform string handling to get it right, since all strings (except shortstrings) have automatic memory management by the compiler. So things happen "behind your back", and in this instance perhaps the timing of the auto-memory managment works against the logic of the function?
There is no bug in the code you posted that I can see.