Skip to content

Commit

Permalink
Fix memory corruption
Browse files Browse the repository at this point in the history
The size of a pointer is always fixed regardless of the data format
chosen.

This causes corruption & random crashes if the chosen format is int16 or
int8
  • Loading branch information
darksylinc committed Mar 11, 2024
1 parent 72e9692 commit f3f8869
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/hostapi/opensles/pa_opensles.c
Original file line number Diff line number Diff line change
Expand Up @@ -893,7 +893,7 @@ static PaError InitializeOutputStream(PaOpenslesHostApiRepresentation *openslesH
(*stream->outputStream->audioPlayer)->GetInterface( stream->outputStream->audioPlayer, SL_IID_PLAY, &stream->outputStream->playerItf );
(*stream->outputStream->audioPlayer)->GetInterface( stream->outputStream->audioPlayer, SL_IID_ANDROIDSIMPLEBUFFERQUEUE, &stream->outputStream->outputBufferQueueItf );

stream->outputStream->outputBuffers = (void **) PaUtil_AllocateMemory( numberOfBuffers * stream->outputStream->bytesPerSample );
stream->outputStream->outputBuffers = (void **) PaUtil_AllocateMemory( numberOfBuffers * sizeof(void*) );
for( i = 0; i < numberOfBuffers; ++i )
{
stream->outputStream->outputBuffers[i] = (void*) PaUtil_AllocateMemory( stream->framesPerHostCallback * stream->outputStream->bytesPerSample
Expand Down Expand Up @@ -995,7 +995,7 @@ static PaError InitializeInputStream( PaOpenslesHostApiRepresentation *openslesH
SL_IID_RECORD,
&stream->inputStream->recorderItf );

stream->inputStream->inputBuffers = (void **) PaUtil_AllocateMemory( numberOfBuffers * stream->inputStream->bytesPerSample );
stream->inputStream->inputBuffers = (void **) PaUtil_AllocateMemory( numberOfBuffers * sizeof(void*) );
for( i = 0; i < numberOfBuffers; ++i )
{
stream->inputStream->inputBuffers[i] = (void*) PaUtil_AllocateMemory( stream->framesPerHostCallback
Expand Down

0 comments on commit f3f8869

Please sign in to comment.