Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Possible error in BrowseCtrl module #51

Open
logachev opened this Issue Sep 3, 2013 · 1 comment

Comments

Projects
None yet
2 participants

logachev commented Sep 3, 2013

Hello,

Please look into code of BrowseCtrl module.
Function GetNextPathName():

    // Make sure pos is a valid position
    if (pos == NULL)
        return _T("");

    if (IsEditManuallyChanged())
    {
        // contents of the edit box has been changed by direct user input
        POSITION posOrig = pos;
        pos = NULL;
        return (DWORD)posOrig == (DWORD)(LPCTSTR)m_sEditText ? m_sEditText : _T("");
    }

    if (m_lpszPathNames == NULL
        || m_nPathNamesLen == 0
        || m_nSelCount == 0
        || (DWORD)pos < (DWORD)m_lpszPathNames
        || (DWORD)pos >= (DWORD)m_lpszPathNames + (DWORD)m_nPathNamesLen)
    {
        pos = NULL;
        return _T("");
    }

But when you call this function from FileDoModal function, m_nSelCount equal to zero etc. So third if in GetNextPathName() function always will return empty string(except EditManuallyChanged situation).

    POSITION pos = dlg.GetStartPosition();

    // determine the string length
    m_nSelCount = 0;
    m_nPathNamesLen = 0;
    while (pos != NULL)
    {
        m_nSelCount++;
        m_nPathNamesLen += dlg.GetNextPathName(pos).GetLength() + 1;
    }

Please correct me if I'm wrong..

Owner

dblock commented Sep 3, 2013

Didn't dig through this yet, but appreciate if you could write a test that reproduces the bug and make a pull request with a fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment