Skip to content

Commit

Permalink
Attempting to load a defective S3M file could trigger two different i…
Browse files Browse the repository at this point in the history
…ssues (Fixes #118)

* Do not call mcpSet() on close, as it might not be set up if loading failed. Trust the wavetable driver to reset itself.
* que variable was not reset to NULL after free(), causing a double free.
  • Loading branch information
mywave82 committed Jul 30, 2024
1 parent 9f19a19 commit c1069f5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
9 changes: 7 additions & 2 deletions playgmd/gmdls3m.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,14 @@ OCP_INTERNAL int LoadS3M (struct cpifaceSessionAPI_t *cpifaceSession, struct gmd
cpifaceSession->cpiDebug (cpifaceSession, "[GMD/S3M] Invalid signature\n");
return errFormSig;
}
if ((hdr.orders>255)||(hdr.pats>=254))
if (hdr.orders>255)
{
cpifaceSession->cpiDebug (cpifaceSession, "[GMD/S3M] too many orders and/or patterns\n");
cpifaceSession->cpiDebug (cpifaceSession, "[GMD/S3M] too many orders (0x%04x > 0x00ff)\n", hdr.orders);
return errFormStruc;
}
if (hdr.pats>=254)
{
cpifaceSession->cpiDebug (cpifaceSession, "[GMD/S3M] too many patterns (0x%04x >= 0x00fe)\n", hdr.pats);
return errFormStruc;
}

Expand Down
6 changes: 1 addition & 5 deletions playgmd/gmdplay.c
Original file line number Diff line number Diff line change
Expand Up @@ -1647,13 +1647,9 @@ OCP_INTERNAL int mpPlayModule (const struct gmdmodule *m, struct ocpfilehandle_t

OCP_INTERNAL void mpStopModule (struct cpifaceSessionAPI_t *cpifaceSession)
{
int i;
for (i=0; i<physchan; i++)
{
cpifaceSession->mcpSet (cpifaceSession, i, mcpCReset, 0);
}
cpifaceSession->mcpDevAPI->ClosePlayer (cpifaceSession);
free(que);
que=0;
}

OCP_INTERNAL void mpGetChanInfo (uint8_t ch, struct chaninfo *ci)
Expand Down

0 comments on commit c1069f5

Please sign in to comment.