Bugs in TMS Cryptography Pack library of September

I have installed the latest TMS Cryptography Pack library, dated 09/23/2025.

I've detected a problem in TXAdES.GenerateSignature, which has two parameters: FilePath: string; OutputFilePath: string. Within that procedure, there is a TStringList named ts, which calls the SaveToFile method like this:

ts.SaveTofile(OutputFilePath).

The problem is that if you pass the FilePath in UTF8, it saves the OutputFilePath in ANSI.

But the more I look at the library, the more it looks like a beta version.

If I include ReportMemoryLeaksOnShutdown := True; in the DPR, I see a lot of memory leaks.

For example, originalDocument: TStringList; It's always created in TXAdES.GenerateSignature, but it's only freed if:

if FPackaging = enveloping then
begin
if originalDocument <> nil then
originalDocument.Free;
end;

I've come to think there might be a problem with the installer. I used TMSSubscriptionManager2.exe to download and install the library in Delphi 10.4.2, but it doesn't install the proper DPK; it installs TMSCryptoPkgDXE13.dpk instead of TMSCryptoPkgDXE14.dpk. I had to manually install the compiler and design packages ending in 14.

Another thing that caught my attention is that there are many object creations that have the "free" call at the end of the procedure or function, but I don't see a corresponding try finally pattern.

This worries me; for example, it occurs in the procedure I mentioned earlier.

Hi Manuel,
Sorry for just noticing your comment now.
Thanks for reporting these issues.
I am aware of the memory leaks and there will be changes in the library next year to remove many of them just with a better class structure.
I missed the "free" issue that you spotted and will fix it, as well as the OutputFilePath issue.

Don't hesitate to send me other issues that you have identified.

I'll pass de .dpk issue to the deployment team.

Regards,
bernard

Hi Manuel,

I checked the code and it requires a better structure and simplifications (lots of cases have been added in the last 6 months).
However, I don't understand this:
"Within that procedure, there is a TStringList named ts, which calls the SaveToFile method like this: ts.SaveTofile(OutputFilePath). The problem is that if you pass the FilePath in UTF8, it saves the OutputFilePath in ANSI."

I saved a file with Chinese characters in the name without any problem using RAD Studio 13.0 patch1.

Also, you are correct with:
"if FPackaging = enveloping then begin
if originalDocument <> nil then
originalDocument.Free;
end;" and the fact that originalDocument is only freed in this case.

Note that in other cases originalDocument is assigned to ts, which is later freed.

Hi Bernard,

I'm using Delphi 10.4.2.

At the time I wrote these comments, I installed the September library that TMS released via TMSSubscriptionManager2.exe.

I had issues with the installation; I had to install it manually because the installer didn't install the design-time package (for some reason).

Before the September update, I was generating signed XML with Enveloped without any issues, but when I updated the library, I noticed the issues I mentioned in my previous post.

The generated .xsig file was in ANSI mode and had a lot of memory leaks.

I can't reinstall the latest library now, but when I have time, I'll test it and report back if the problem persists or is fixed.

Thanks.

OK, no problem.
I am working on the memory leaks but most of them won't disappear with the next release. They will require more cleanup in the classes and a bit of retructuring (the current version is a straight port from C and can definitely be improved).