Browse Source

fixed a memory leak in FPC.

Ugochukwu Mmaduekwe 8 years ago
parent
commit
eba81cad04
1 changed files with 7 additions and 1 deletions
  1. 7 1
      CryptoLib/src/Asn1/ClpDerBmpString.pas

+ 7 - 1
CryptoLib/src/Asn1/ClpDerBmpString.pas

@@ -154,7 +154,12 @@ var
   i: Int32;
 begin
   System.SetLength(c, System.Length(Str));
-  StrPLCopy(PChar(@c[0]), Str, System.Length(c));
+
+  // had to use this loop because somehow, StrPLCopy causes memory leak in FPC v3.0.5
+  For i := System.Low(Str) to System.High(Str) do
+  begin
+    c[i - 1] := Str[i];
+  end;
   System.SetLength(b, System.Length(c) * 2);
 
   i := 0;
@@ -167,6 +172,7 @@ begin
   end;
 
   derOut.WriteEncoded(TAsn1Tags.BmpString, b);
+
 end;
 
 class function TDerBmpString.GetInstance(obj: TObject): IDerBmpString;