ErikHebeler / delphichromiumembedded

Automatically exported from code.google.com/p/delphichromiumembedded
0 stars 1 forks source link

Access violation in TCefPostDataRef.GetElements(Count: Cardinal) #38

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I'm getting an access violation with the last release r136 (CEF 1.963.439) when 
calling TCefPostDataRef.GetElements in a custom scheme.

What steps will reproduce the problem?

ProcessRequest(const Request: ICefRequest;
  const callback: ICefSchemeHandlerCallback)
var
 DSize: Cardinal;
 IL: IInterfaceList;
begin
 DSIze := request.PostData.GetCount;
 if DSize > 0 then
 begin
  IL := request.PostData.GetElements(DSize);

...

What is the expected output? What do you see instead?

Access violation instead of the POSTDATA items.

What version of the product are you using? On what operating system?

Delphi XE2 - Windows 7 x64

Please provide any additional information below.

The error happens here:
PCefPostData(FData)^.get_elements(PCefPostData(FData), @Count, items);

in

function TCefPostDataRef.GetElements(Count: Cardinal): IInterfaceList;
var
  items: PCefPostDataElementArray;
  i: Integer;
begin
  Result := TInterfaceList.Create;
  GetMem(items, SizeOf(PCefPostDataElement) * Count);
  try
    PCefPostData(FData)^.get_elements(PCefPostData(FData), @Count, items);
    for i := 0 to Count - 1 do
      Result.Add(TCefPostDataElementRef.UnWrap(items[i]));
  finally
    FreeMem(items);
  end;
end;

Original issue reported on code.google.com by guillaum...@yahoo.fr on 1 Feb 2012 at 6:29

GoogleCodeExporter commented 9 years ago
I cant reproduce this error in current SVN revision, I assume it has been fixed 
in CEF

Original comment by hgourv...@gmail.com on 7 Feb 2012 at 10:10

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I'm reproducing the same issue, I'll try to come up with a sample, but 
apparently any form post handled in BeforeResourceLoad triggers the issue.

Original comment by zar...@gmail.com on 20 Feb 2012 at 2:06

GoogleCodeExporter commented 9 years ago
May not be exactly the same issue, but the error is similar, and the test case 
quite minimal: starting from guiclient, change default url to 'test', then in 
OnBeforeResourceLoad, place the following code

var
   buf : AnsiString;
   intfList : IInterfaceList;
   n : Cardinal;
begin
   if request.Method<>'POST' then begin
      buf:= 'Hello <form action="act" method="post" id="frm">'
           +'<input type="hidden" name="field" value="val" />'
           +'<button onclick="document.getElementById(''frm'').submit()" />';
      response.MimeType:='text/html';
      resourceStream:=TCefStreamReaderRef.CreateForData(PAnsiChar(buf), Length(buf));
   end else begin
      n:=request.PostData.GetCount;              // passes 
      intfList:=request.PostData.GetElements(n); // passes
      intfList:=nil;                             // passes
      Assert(n=request.PostData.GetCount);       // passes
      intfList:=request.PostData.GetElements(n); // crash here
   end;
end;

Run and click on the button. The second GetElements() will fail.

In my original (less minimal) code, there is only a single GetElements(), but 
many other properties of the request are accessed.

Original comment by zar...@gmail.com on 20 Feb 2012 at 2:46