Changeset 7d3cc85d1bc8a3d7aea4f5486148826304b0aa8b

Show
Ignore:
Timestamp:
03/15/08 15:50:27 (6 months ago)
Author:
Richard Hosking <richard@hovis.net>
git-committer:
Richard Hosking <richard@hovis.net> 1205592627 +0000
git-parent:

[a19cac2195024dc9992fa582eeb4701602695003]

git-author:
Richard Hosking <richard@hovis.net> 1205592627 +0000
Message:

Fix very minor memory leak when using OSS for audio.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/access/v4l2/v4l2.c

    r9630c00 r7d3cc85  
    24522452                            vlc_bool_t b_demux ) 
    24532453{ 
    2454     char *psz_device = p_sys->psz_adev; 
    24552454    int i_fd = 0; 
    24562455    int i_format; 
    24572456    /* OSS */ 
    2458     if( !psz_device ) psz_device = strdup( OSS_DEFAULT ); /* FIXME leak */ 
    2459  
    2460     if( (i_fd = open( psz_device, O_RDONLY | O_NONBLOCK )) < 0 ) 
     2457    char* psz_oss_device_name = strdup( ( !p_sys->psz_adev ) ? OSS_DEFAULT : p_sys->psz_adev ); 
     2458 
     2459    if( (i_fd = open( psz_oss_device_name, O_RDONLY | O_NONBLOCK )) < 0 ) 
    24612460    { 
    24622461        msg_Err( p_this, "cannot open OSS audio device (%m)" ); 
     
    24912490    if( !p_sys->psz_adev ) 
    24922491        p_sys->psz_adev = strdup( OSS_DEFAULT ); 
     2492    free( psz_oss_device_name ); 
    24932493    return i_fd; 
    24942494 
    24952495 adev_fail: 
    24962496 
     2497    free( psz_oss_device_name ); 
    24972498    if( i_fd >= 0 ) close( i_fd ); 
    24982499    return -1; 
     
    28942895    int i_fd = 0; 
    28952896    int i_caps; 
    2896     if( !psz_device ) psz_device = strdup( OSS_DEFAULT ); /* FIXME leak */ 
    2897  
    2898     if( ( i_fd = open( psz_device, O_RDONLY | O_NONBLOCK ) ) < 0 ) 
    2899     { 
    2900         msg_Err( p_this, "cannot open device %s for OSS audio (%m)", psz_device ); 
     2897    char* psz_oss_device_name = strdup( ( !psz_device ) ? OSS_DEFAULT : psz_device ); 
     2898 
     2899    if( ( i_fd = open( psz_oss_device_name, O_RDONLY | O_NONBLOCK ) ) < 0 ) 
     2900    { 
     2901        msg_Err( p_this, "cannot open device %s for OSS audio (%m)", psz_oss_device_name ); 
    29012902        goto open_failed; 
    29022903    } 
     
    29092910    } 
    29102911 
     2912    free( psz_oss_device_name ); 
    29112913    if( i_fd >= 0 ) close( i_fd ); 
    29122914 
     
    29142916 
    29152917open_failed: 
     2918    free( psz_oss_device_name ); 
    29162919    if( i_fd >= 0 ) close( i_fd ); 
    29172920    return VLC_FALSE;