Arno Garrels wrote: > > I fixed this bug in October in both V5 and V6.
Sorry, not in October but in August. > http://www.duodata.de/misc/delphi/SmtpProt_08132006.zip > > The problem is that TStrings.Text is not available in Delph1, > that's why Francois exchanged my line "if Length(FMailMessage.Text) > > 0 then" > by "if FMailMessage.GetText^ <> #0 then" which leaks memory. > I don't know why my fixes are missing in current code. > > --- > Arno Garrels [TeamICS] > http://www.overbyte.be/eng/overbyte/teamics.html > > >> Memory is allocated but not released for each >> email Sent: >> unencoded: slightly larger than the body of the email, >> encoded: slightly larger than twice the body of the email. >> >> The current source is: >> {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * >> * * * * *} >> procedure TSmtpCli.PrepareEMail; >> {var >> I : Integer;} >> begin >> FBodyFlag := TRUE; >> FCurrentFile := 0; >> FBodyLine := 0; >> FFileStarted := FALSE; >> FEncoding := FDefaultEncoding; >> {AG} {AG start} >> { FMailMessage.Text is being encoded/wrapped later on the fly, >> } { see also TriggerGetData and DoGetMsgTextLine >> } {if Length(FMailMessage.Text) > 0 then} { FP 05/03/06 } >> if FMailMessage.GetText^ <> #0 then >> FMailMsgTextPos := 1 >> else >> FMailMsgTextPos := 0; >> >> { Check if we have to change Encoding. >> } if (FMailMsgTextPos > 0) and >> (FEncoding in [smtpEnc7bit, smtpEnc8bit]) and (not >> FAllow8bitChars) then >> if NeedsEncodingPChar(FMailMessage.GetText) then {FP} >> if NeedsEncoding(FMailMessage.Text) then >> FEncoding := smtpEncQuotedPrintable; >> {AG end} >> ... >> {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * >> * * * * *} >> >> The "GetText" is the culprit, it is described in Delphi help for >> TStrings.GetText: "Call GetText to obtain a dynamically allocated >> character buffer containing all of the strings in the list. >> Individual strings are separated by a carriage return and (on >> Windows) line feed. The caller is responsible for freeing the >> returned value using the StrDispose procedure." A pointer to the >> buffer created by GetText was not saved so you could not free it. >> >> The problem can be fixed one of two ways: 1) store the pointer to the >> Character buffer then free it when it is no longer needed, or 2) or >> change the code as follows: >> {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * >> * * * * *} >> procedure TSmtpCli.PrepareEMail; >> {var >> I : Integer;} >> begin >> FBodyFlag := TRUE; >> FCurrentFile := 0; >> FBodyLine := 0; >> FFileStarted := FALSE; >> FEncoding := FDefaultEncoding; >> {AG} {AG start} >> { FMailMessage.Text is being encoded/wrapped later on the fly, >> } { see also TriggerGetData and DoGetMsgTextLine >> } {if Length(FMailMessage.Text) > 0 then} { FP 05/03/06 } >> //CE if FMailMessage.GetText^ <> #0 then >> if FMailMessage.Count > 0 then >> //CE FMailMsgTextPos := 1 >> else >> FMailMsgTextPos := 0; >> >> { Check if we have to change Encoding. >> } if (FMailMsgTextPos > 0) and >> (FEncoding in [smtpEnc7bit, smtpEnc8bit]) and (not >> FAllow8bitChars) then >> //CE if NeedsEncodingPChar(FMailMessage.GetText) then {FP} >> if NeedsEncoding(FMailMessage.Text) then {FP} >> //CE if NeedsEncoding(FMailMessage.Text) then >> FEncoding := smtpEncQuotedPrintable; >> {AG end} >> ... >> {* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * >> * * * * *} >> >> Carl Efird -- To unsubscribe or change your settings for TWSocket mailing list please goto http://www.elists.org/mailman/listinfo/twsocket Visit our website at http://www.overbyte.be
