Bug report : Win32Module::load crashes

Hi,

I am developping a host application and just installed 3.7.5 and Win32Module::load method will crash for some 32 bit plugin on a 64 bit system.

The plugin is DSPplug mark3 from DSPplug. The problem is that the GetLastError function returns a 193 error code but the FormatMessageA function does not allocate memory for lpMessageBuffer. Then, refering to the content of this null pointer will make the application crash. :

std::string ((char*)lpMessageBuffer);

Here is a small modification of this method that solve the problem! Just checking if lpMessageBuffer is null before using it!

bool load (const std::string& inPath, std::string& errorDescription) override
{
filesystem::path p (inPath);
auto filename = p.filename ();
p /= “Contents”;
p /= architectureString;
p /= filename;
auto wideStr = StringConvert::convert (p.string ());
mModule = LoadLibraryW (reinterpret_cast (wideStr.data ()));
if (!mModule)
{
wideStr = StringConvert::convert (inPath);
mModule = LoadLibraryW (reinterpret_cast (wideStr.data ()));
if (!mModule)
{
auto lastError = GetLastError ();
LPVOID lpMessageBuffer;
FormatMessageA (FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
nullptr, lastError, MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPSTR)&lpMessageBuffer, 0, nullptr);
if(lpMessageBuffer)
{
errorDescription = "LoadLibray failed: " + std::string ((char*)lpMessageBuffer);
LocalFree (lpMessageBuffer);
}
else
{
errorDescription = “LoadLibray failed!”;
}

			return false;
		}
	}
	auto factoryProc = getFunctionPointer<GetFactoryProc> ("GetPluginFactory");
	if (!factoryProc)
	{
		errorDescription = "The dll does not export the required 'GetPluginFactory' function";
		return false;
	}
	// InitDll is optional
	auto dllEntry = getFunctionPointer<InitModuleFunc> ("InitDll");
	if (dllEntry && !dllEntry ())
	{
		errorDescription = "Calling 'InitDll' failed";
		return false;
	}
	auto f = Steinberg::FUnknownPtr<Steinberg::IPluginFactory> (owned (factoryProc ()));
	if (!f)
	{
		errorDescription = "Calling 'GetPluginFactory' returned nullptr";
		return false;
	}
	factory = PluginFactory (f);
	return true;
}

HINSTANCE mModule {nullptr};

};

Thanks for the report. We will fix it in the next update.

Thank you very much!