]> Repos - portaudio/commitdiff
Alsa: Fix memory leak as nonMmapBuffers were not freed (since change to realloc)...
authorgineera <gineera@0f58301d-fd10-0410-b4af-bbb618454e57>
Thu, 22 Aug 2013 22:01:17 +0000 (22:01 +0000)
committergineera <gineera@0f58301d-fd10-0410-b4af-bbb618454e57>
Thu, 22 Aug 2013 22:01:17 +0000 (22:01 +0000)
src/hostapi/alsa/pa_linux_alsa.c

index 6885fc1a4bb2335799f0e2a87882dfe69b6764a9..32c1f7682339b50abc0d32cbb855f02bcb97a614 100644 (file)
@@ -1898,8 +1898,8 @@ error:
 static void PaAlsaStreamComponent_Terminate( PaAlsaStreamComponent *self )
 {
     alsa_snd_pcm_close( self->pcm );
-    if( self->userBuffers )
-        PaUtil_FreeMemory( self->userBuffers );
+    PaUtil_FreeMemory( self->userBuffers ); /* (Ptr can be NULL; PaUtil_FreeMemory includes a NULL check) */
+    PaUtil_FreeMemory( self->nonMmapBuffer );
 }
 
 /*
@@ -3450,13 +3450,6 @@ static PaError PaAlsaStreamComponent_EndProcessing( PaAlsaStreamComponent *self,
 
     if( self->canMmap )
         res = alsa_snd_pcm_mmap_commit( self->pcm, self->offset, numFrames );
-    else
-    {
-        /* using realloc for optimisation
-        free( self->nonMmapBuffer );
-        self->nonMmapBuffer = NULL;
-        */
-    }
 
     if( res == -EPIPE || res == -ESTRPIPE )
     {