Skip to content

Commit

Permalink
Minor fix for reading CD-Text.
Browse files Browse the repository at this point in the history
  • Loading branch information
enzo1982 committed Sep 11, 2018
1 parent af985ed commit 947001b
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions components/decoder/cdrip/info/cdtext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ Int BoCA::CDText::ReadCDText(Int drive)

for (Int j = 0; j < 12; j++) lpszBuffer[nInsertPos++] = pCDtextPacks->data[j];

while (nInsertPos > 0 && (lpZero = (char *) memchr(lpszBuffer, '\0', nInsertPos)) != NIL)
while (nInsertPos > 0)
{
Int nOut = (lpZero - lpszBuffer) + 1;

/* Update text data.
*/
if (pCDtextPacks->packType == 0x80) // Album/Track title
{
if (pCDtextPacks->trackNumber == 0) cdInfo.SetTitle(lpszBuffer);
Expand All @@ -82,6 +82,12 @@ Int BoCA::CDText::ReadCDText(Int drive)
else cdInfo.SetTrackArtist(pCDtextPacks->trackNumber, lpszBuffer);
}

/* Shift buffer if terminated.
*/
if ((lpZero = (char *) memchr(lpszBuffer, '\0', nInsertPos)) == NIL) break;

Int nOut = (lpZero - lpszBuffer) + 1;

nInsertPos -= nOut;

memmove(lpszBuffer, lpZero + 1, 1024 - nOut -1);
Expand Down

0 comments on commit 947001b

Please sign in to comment.