[vlc-devel] [PATCH 1/1] codec/dirac: Rewrite libdirac(-research) encoding support

David Flynn davidf+nntp at woaf.net
Tue Nov 11 18:23:24 CET 2008


On 2008-11-11, Laurent Aimar <fenrir at via.ecp.fr> wrote:
> On Mon, Nov 10, 2008, David Flynn wrote:
>> >  psz_tmp may be NULL in case of allocation failure.`
>> Pointless allocation failure checks be damned.
>> I've just gone and deleted all the validation of psz_tmp sice it was
>> pointed out it returned "", i'm a little peeved at having to put them
>> all back.
>  Well, it is the current policy, that new codes do not segfault on
> allocation failure so ... 
>  Using var_GetNonEmptyString may be the easiest way in your code, it will either
> return NULL or a non empty string. It will merge the NULL and "" case in one.
> (You can just handle allocation failures as a case where no value is provided)

I don't quite follow.

Actually, i've just noticed that we were safe from this until i just
redid the fix i undid.

I was at one point doing:
psz_tmp = var_GetString(...);
if(0) {}
else if(...) {
...
}
else {
   msg_Err( p_enc, "Whatsname invalid: %s", psz_tmp );
   free( psz_tmp );
   goto error;
}
free( psz_tmp );

Which as far as i can tell is fine (provided that msg_Err can cope with
a null string being passed to it).

So my way merged the NULL, empty and invalid string into one.

..david




More information about the vlc-devel mailing list