I've got some code that worked fine under Delphi 2007 but breaks under D2010. It involves passing in a string, converting it to a PWideChar (specifically, a WideString pointer, not a UnicodeString pointer), doing some processing, and then calling SysFreeString on it. It works fine until a blank string is passed in, then SysFreeString breaks. It calls a bunch of things that end up raising an Int 3
breakpoint inside NTDLL.DLL. Continuing past this point results in
Project raised exception class $C0000005 with message 'access violation at 0x7747206e: read of address 0x539b8dba'.
Which, if you look closely, is not the standard Access Violation message.
The top of the stack trace when it hits the Int 3
looks like this:
:774e475d ; ntdll.dll
:774afad0 ; ntdll.dll
:774e5de9 ; ntdll.dll
:774a6dff ; ntdll.dll
:76fc1075 ; C:\Windows\system32\ole32.dll
:770e443a ; C:\Windows\system32\oleaut32.dll
:770e3ea3 oleaut32.SysFreeString + 0x4a
Does anyone have any idea what's going on here?
Edit (from the comments):
This isn't a WideString, though. It's a PWideChar generated by StringToOleStr, and there are no double-free errors when a non-blank string is passed in. Unfortunately, I can't really post a code sample because this is a third-party component that's under copyright. (And I can't ask them for support because it's no longer supported. Basically, the whole thing's one big mess.)