Menu

#179 TOvcCustomPictureField.efTransfer bug

closed-fixed
nobody
None
5
2011-03-19
2009-05-28
Zig
No

My colleague found a bug when testing the going through the code.
When the field was empty and visually edited, he got an AV.

This is the part he has fixed, the efFieldIsEmpty:

"end else if efFieldIsEmpty or (Length(SP^) <> MaxLength) then begin
if efFieldIsEmpty or (String(DataPtr^) = '') then // SZ"

Here is his proposed fix in it's entirety:
********* BEGIN CODE *************
function TOvcCustomPictureField.efTransfer(DataPtr : Pointer; TransferFlag : Word) : Word;
{-transfer data to/from the entry fields}
var
// P : PChar absolute DataPtr; //SZ not used
SP : ^String absolute DataPtr;
Code : Integer;

procedure TransferString;
{-transfer data to/from string type entry fields}
var
A : TEditString;
begin
if TransferFlag = otf_GetData then begin
if (efoTrimBlanks in Options) and efFieldIsEmpty then
SP^ := ''
else begin
{get copy of the edit string}
if (efoStripLiterals in Options) then
pbStripLiterals(A, efEditSt)
else
StrCopy(A, efEditSt);

{trim leading and trailing blanks}
if (efoTrimBlanks in Options) then
TrimAllSpacesPChar(A);

SP^ := StrPas(A);
end;
end else if efFieldIsEmpty or (Length(SP^) <> MaxLength) then begin
if efFieldIsEmpty or (String(DataPtr^) = '') then // SZ
efEditSt[0] := #0
else
StrPLCopy(efEditSt, SP^, MaxLength);
pbMergePicture(efEditSt, efEditSt);
end else
StrPLCopy(efEditSt, SP^, MaxLength);
end;

********** END CODE *********

Discussion

  • Armin Biernaczyk

    • status: open --> closed-fixed
     
  • Armin Biernaczyk

    Apperently, this issue had already been resolved some time ago; however, whilst cross-checking, a minor bug was discovered and fixed in rev 194.

     

Log in to post a comment.

MongoDB Logo MongoDB