microsoft / AppModelSamples

Sample code for AppModel features
MIT License
200 stars 102 forks source link

Wrong index used in EnumCommands::Next #38

Open acs-godonnell opened 9 months ago

acs-godonnell commented 9 months ago

The index on apUICommand is always 0ul here, so only one command is ever returned. It should be i or fetched I think.

https://github.com/microsoft/AppModelSamples/blob/0c019d835d194dfc65ee0c0663086582d48165a9/Samples/SparsePackages/PhotoStoreContextMenu/dllmain.cpp#L154

    // IEnumExplorerCommand
    IFACEMETHODIMP Next(ULONG celt, __out_ecount_part(celt, *pceltFetched) IExplorerCommand** apUICommand, __out_opt ULONG* pceltFetched)
    {
        ULONG fetched{ 0 };
        wil::assign_to_opt_param(pceltFetched, 0ul);

        for (ULONG i = 0; (i < celt) && (m_current != m_commands.cend()); i++)
        {
            m_current->CopyTo(&apUICommand[0]);
            m_current++;
            fetched++;
        }

        wil::assign_to_opt_param(pceltFetched, fetched);
        return (fetched == celt) ? S_OK : S_FALSE;
    }

IEnumExplorerCommand::Next