Hello, folks!
I tried to enumerate the frames of an ID3Tag object
in Visual C# .NET, but it threw an IndexOutOfRange
exception every time the enumerator was entered.
Since an IndexOutOfRange exception cannot
(usually) occur in a foreach loop, i took a look at
EnumFields.cpp of ID3Com and found a bug.
In CEnumFields::Next(), *pceltFetched is used to
determine the number of fields that should be
fetched. This is wrong, the number of fields to be
fetched is passed in celt. *pceltFetched should
received the number of elements returned.
The following code works for me:
...
for (long i = 0; i < celt && m_currentNum+i <
NumItems; i++) {
IID3ComFrame* Frame;
...
rgelt++;
}
m_CurrentNum += i;
if (pceltFetched) // dunno... can pceltFetched be null
if celt == 1 ??
*pceltFetched = i;
return S_OK;
ID3Com is great, saves a lot of time =)
Logged In: YES
user_id=787239
Before "if (pceltFetched)":
if (!i)
return S_FALSE;
:-)
(It's not 100% okay if pceltFetched == null && celt > 1,
how does the caller know how many objects are
returned? Perhaps an E_FAIL should be returned in that
case...)