c++ - CString.Format crashes in 32-bit -


i have cstring format causes crash in 32-bit unicode mfc static/vs2013 project in sdk file output.c line 1629 while (i-- && *pwch)

bool myclass::function1(lpctstr sappname, hkey hkey, lpctstr tcszvalue1, lpctstr tcszvalue2, lpctstr tcszvalue3, bool bvalue) {          __int64 nappid=0;     __int64 nid2=0;     ssql.format(_t("insert table (appid, id2, regpath, regkey, regvaluename,           brecursedelete, removeit) values ('%d', '%d', '%s', '%s', '%s', '%d', 1)"),           nappid, nid2, tcszvalue1, tcszvalue2, tcszvalue3, bvalue); } 

when compile in 64-bit works without problem, in 32-bit crashes when svalue3 empty (but not first time, on 4th call cstring.format when svalue empty)

you must use %lld format specifier instead of %d specifier.

in 32 bit world, %d expects 32 bit integer. provide 64 bit integers arguments. therefore undefined behaviour because format completly mix arguments.


Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

c# - two queries in same method -