ID: Q189765
The information in this article applies to:
- Microsoft Windows NT 4.0
When you are freeing or resizing a buffer that is pointed to by the ActualSourceFileName parameter of SetupGetFileCompressionInfo, the LocalFree function or any of the other default process heap functions (including LocalReAlloc, GlobalFree, and GlobalRealloc) might cause an Access Violation error in an application.
The Setup API functions do not use the process's default heap to manage memory. If you pass the ActualSourceFileName buffer pointer to LocalFree, it will eventually corrupt the process's default heap.
The SetupAPI.dll library exports a function named MyFree(). This function frees the memory that has been allocated by SetupGetFileCompressionInfo. To resolve this problem, dynamically link your application to MyFree in SetupAPI.dll and use it to free the memory.
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. We are researching this bug and will post new information here in the Microsoft Knowledge Base as it becomes available.
The second parameter of SetupGetFileCompressionInfo() is the address of an LPSTR variable. If the function succeeds, SetupGetFileCompressionInfo() returns the full path of the file that was loaded. The documentation incorrectly states that you should free this string with a call to LocalFree(). Instead, the application should use MyFree().
Following is an example of how to obtain the MyFree() function from the SetupAPI.dll:
typedef VOID (WINAPI* MYFREEFUNC)(LPVOID lpBuff);
MYFREEFUNC MyFree;
HMODULE hDll=NULL;
hDll = GetModuleHandle("SETUPAPI.DLL");
MyFree = (MYFREEFUNC)GetProcAddress(hDll, "MyFree");
...
other code here to prepare file queue
...
PTSTR lpActualSourceFileName;
SetupGetFileCompressionInfo(...,&lpActualSourceFileName,...,...,...);
...
MyFree(lpActualSourceFileName);
If the call to LocalFree is causing an Access Violation, you should solve
the problem by using MyFree().
Additional query words: 4.0 LocalAlloc GlobalAlloc crash gpf fault
Keywords : kbAPI kbKernBase kbMemory
Issue type : kbbug
Solution Type : kbpending
Last Reviewed: July 21, 1998