Menu

#1403 Weird code in multiformatText.cpp

open
nobody
None
4
2012-12-21
2006-12-02
Kimmo Varis
No

SVN trunk.

Look at functions:
storageForPlugins::GetDataFileUnicode()
and
storageForPlugins::GetDataFileAnsi()

These casts just can't be correct:

line 259:
textRealSize = MultiByteToWideChar(m_codepage, flags, pchar, nchars, (WCHAR*)((char*)fileDataOut.pMapBase+bom_bytes), textForeseenSize-1)* sizeof(WCHAR);

Line 482:
pwchar = (WCHAR*) ((char*)fileDataIn.pMapBase+2); // pass the BOM

What the heck somebody thought when he wrote those casts?

Anyway, seems that whole file needs careful review and cleanup. Maybe few bugs get fixed while doing it..

Discussion

  • Takashi Sawanaka

    Logged In: YES
    user_id=954028
    Originator: NO

    Do you mean like the code below?

    Line 482:
    pwchar = (WCHAR*)fileDataIn.pMapBase+1; // pass the BOM

     
  • Kimmo Varis

    Kimmo Varis - 2006-12-03

    Logged In: YES
    user_id=631874
    Originator: YES

    Yes, that is already a lot easier to understand. I'm don't know why there are those (char *) casts in original code. And I'm afraid they cause some wrong results also, like pointing to wrong byte in WCHAR type.

     

Log in to post a comment.

MongoDB Logo MongoDB