Subject IBO BUG: Resource Leak in IB_Components (verified in C++ Builder 6)
Author zachs78
Dear All,

We've encountered a resource leak in IB_Components (as reported by
Codeguard).
To reproduce (100% reproduceable), follow these steps:

Create an 'empty' DLL (we'll call it Leak.dll):

#include <vcl.h>
#include <windows.h>
#pragma hdrstop
#pragma link "IB_Components" // this is the culprit!!!
// replacing this with our own components did not yield any resource
leaks
//---------------------------------------------------------------------------
#pragma argsused
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*
lpReserved)
{
return 1;
}
//---------------------------------------------------------------------------

in your test program, do the following:

for (int i=0; i<100; i++)
{
HANDLE h = LoadLibrary("<foldername>\\Leak.dll");
FreeLibrary(h);
}

Run the test program with Codeguard ENABLED.

Codeguard will show resource leak upon termination of application. The
number of resource leaks will be the number of times we have looped in the
above code snippet.

Error 00065. 0x300010 (Thread 0x099C):
Resource leak: The memory block (0x3098120) was never freed

The memory block (0x03098120) [size: 36 bytes] was allocated with
SysGetMem
Call Tree:
0x033F314F
0x3267E2F5(=CC3260MT.DLL:0x01:07D2F5)
0x3267E813(=CC3260MT.DLL:0x01:07D813)
0x03351480
0x7C91CBAB(=ntdll.dll:0x01:01BBAB)
0x7C916178(=ntdll.dll:0x01:015178)


Is there a workaround for this bug?
We've tested both versions 4.5 Ai and B.

We're suspecting it is the Delphi Initialization and Finalization code
that is causing the problem. We tested it using C++ Builder 6 with SP4.

Regards,
Zach