[vlc-devel] [PATCH] playlist/directory: ignore case when sorting files

Francois Cartegnie fcvlcdev at free.fr
Thu Aug 20 16:35:13 CEST 2015


Le 20/08/2015 16:13, Thomas Guillem a écrit :
> 
> 
> On Thu, Aug 20, 2015, at 15:30, Francois Cartegnie wrote:
>> Le 20/08/2015 14:48, Thomas Guillem a écrit :
>>> +#ifdef HAVE_STRCOLL
>>> +    /* The program's LOCAL defines if case is ignored */
>>> +
>>> +    /* strxfrm(NULL, src, 0) returns the number of bytes required for the
>>> +     * transformation */
>>> +    char *psz_name1 = malloc( strxfrm( NULL, p1->psz_name, 0 ) + 1 );
>>> +    char *psz_name2 = malloc( strxfrm( NULL, p2->psz_name, 0 ) + 1 );
>>> +    if( !psz_name1 || !psz_name2 )
>>> +        return 0;

Leaks on failure.

> The first call to strxfrm with NULL and 0 arguments returns the size
> needed for the transformation. Therefore, the second call to strxfrm
> with the same string can't fail since the dst buffer is allocated with
> the good size.

You can't tell if first call has failed, which will always allocate 1
byte, at least (assuming it sets size to 0 on failure).

Francois


More information about the vlc-devel mailing list