View Issue Details

IDProjectCategoryView StatusLast Update
0005902JEDI VCL00 JVCL Componentspublic2012-09-10 14:15
ReporterAriochAssigned ToAHUser 
PrioritynormalSeveritycrashReproducibilityalways
Status resolvedResolutionfixed 
PlatformOSWindowsOS Version
Product Version 
Target VersionFixed in Version3.46 
Summary0005902: LoadDLL was sent into death spirale
Description// $Id: JvJCLUtils.pas,v 1.174 2006/02/16 20:28:05 ahuser Exp $
 
function LoadDLL(const LibName: string): THandle;
var
  ErrMode: Cardinal;
begin
  ErrMode := SetErrorMode(SEM_NOOPENFILEERRORBOX);
  Result := LoadLibrary(PChar(LibName));
  SetErrorMode(ErrMode);
  if Result < HINSTANCE_ERROR then
    OSCheck(False);
end;

---------------
// $Id: JvJCLUtils.pas 13219 2012-02-24 10:56:45Z obones $

{$IFDEF MSWINDOWS}
{ Service routines }

function LoadDLL(const LibName: string): THandle;
begin
  Result := SafeLoadLibrary(LibName);
  if Result <> 0 then
    OSCheck(False);
end;
Steps To ReproduceI don't know WHO did THIS simplification, but after half a day spent into gu..

Okay, i should spot that simple error earlier.
Problem is that simple errors are hard to believe hence hard to spot

 - What should this function return ?
 - DLL Handler.

 - Is DLL Handler zero ?
 - No.

 - When will this function return without raising error ?
 - Only when DLL failed to load.
Additional InformationI believe that the condition should be reverted.

function LoadDLL(const LibName: string): THandle;
begin
  Result := SafeLoadLibrary(LibName);
  if Result < HINSTANCE_ERROR then
    OSCheck(False);
end;
TagsNo tags attached.

Activities

AHUser

2012-06-09 11:02

developer   ~0019810

Fixed in svn revision 13308.

You shouldn't use HINSTANCE_ERROR in combination with (Safe)LoadLibrary. LoadLibrary returns zero if it fails.

Issue History

Date Modified Username Field Change
2012-06-07 17:14 Arioch New Issue
2012-06-09 11:02 AHUser Note Added: 0019810
2012-06-09 11:02 AHUser Status new => resolved
2012-06-09 11:02 AHUser Fixed in Version => Daily / SVN
2012-06-09 11:02 AHUser Resolution open => fixed
2012-06-09 11:02 AHUser Assigned To => AHUser
2012-09-10 14:15 obones Fixed in Version Daily / SVN => 3.46