crash : switched from dynamic to static mfc42.dll - string concatenating causes

Folks !

I've encountered a strange problem with a small dialog-based app. I use MSVC++ 6.0 SP3, WinNT 4.0 SP5 and DAO 3.51 (access97)

I wrote a small dialog-app, that is capable of importing a non-replicated database into a replicated database master. In the first place, I distributed the app with dynamic linking to the mfc42.dll but did not ship the dll with the app.
I assumed the correct dll on the target system until I realized, that the tool could be run on a system where this version of the mfc42.dll might not be installed. The user gets an error message like '...could not find ordinal xxxx in mfc42.dll'. (this tool usually goes out together with some other app that ARE installing the correct dll's)

So far, so good.

Now, I switched the linker settings to link the mfc42.dll statically into the application, which he actually did. Since that time I get an 'invalid heap pointer' every time the code tries to concat two string together, no matter of how realizing it. I've tried things like :

CString aString:
aString = "some text : ";
astring += "another text";

or

CString aString;
aString.Format("some text : %s",pOtherText);
// where pOtherText is a (valid) pointer to 'another text'

or

CString aString = "some text : ";
aString = aString + "another text";

I think, I've tried 99% of all ways to concat two strings, but no cigar !

I tested this behaviour on a couple of other machines/platforms, all of them produced the same bug.
[1620 byte] By [Stege] at [2007-11-15 22:14:46]
# 1 Re: crash : switched from dynamic to static mfc42.dll - string concatenating causes
I remember reading somewhere that the some of the runtime libraries don't handle the old standby string functions safely.

I can't remember where I saw it, as amazing as it may seem it's true, but it has to do with the runtime libraries and the
defaultlib "LIBC" conflicts with use of other libs...
warning message you may be overlooking when you compile.

have you tried:

outstring[100];
sprintf( outstring, "%s%s", instring1, instring2);
Phil Christensen at 2007-11-10 3:06:56 >