tiensitu86 / delphichromiumembedded

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

Incorrect usage of INVALID_HANDLE_VALUE for LoadLibrary (CefLoadLib) #1

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
CefLoadLib assumes that when LoadLibrary returns value <> INVALID_HANDLE_VALUE, 
then it's succeed. But if LoadLibrary fails, then it returns 0/NULL. See: 
http://msdn.microsoft.com/en-us/library/ms684175(VS.85).aspx

My suggestion is change code to this one:
http://code.google.com/p/delphichromiumembedded/source/browse/trunk/ceflib.pas#2
845
var
  LibHandle: THandle = 0;

procedure CefLoadLib(const cache: ustring);
begin
  if LibHandle = 0 then
  begin
    LibHandle := LoadLibrary(LIBCEF);
    if LibHandle = 0 then
      RaiseLastOSError;

    cef_string_length := GetProcAddress(LibHandle, 'cef_string_length');
    ...

Original issue reported on code.google.com by krystian...@gmail.com on 8 Aug 2010 at 5:38

GoogleCodeExporter commented 9 years ago
... and of course:
http://code.google.com/p/delphichromiumembedded/source/browse/trunk/ceflib.pas#3
319

finalization
  if LibHandle <> 0 then
  begin
    cef_shutdown;
    FreeLibrary(LibHandle);
  end;

Original comment by krystian...@gmail.com on 8 Aug 2010 at 5:40

GoogleCodeExporter commented 9 years ago
Thank you

Original comment by hgourv...@gmail.com on 16 Aug 2010 at 8:13

GoogleCodeExporter commented 9 years ago
This two changes must be also applied (as in initial report), without this 
program gets AV on cef_shutdown (finalization) if CEF wasn't used.

http://code.google.com/p/delphichromiumembedded/source/browse/trunk/ceflib.pas#2
845
var
  LibHandle: THandle = 0; <---

procedure CefLoadLib(const cache: ustring);
begin
  if LibHandle = 0 then <---

Original comment by krystian...@gmail.com on 21 Aug 2010 at 11:29