[vlc-devel] commit: libvlc: Fix a typo in a memcpy and constify. (Pierre d'Herbemont )

Rémi Denis-Courmont remi at remlab.net
Fri Jun 5 09:33:56 CEST 2009


On Fri, 5 Jun 2009 09:10:48 +0200, jpd at videolan.org wrote:
> On Fri, Jun 05, 2009 at 07:34:57AM +0200, git version control wrote:
>> vlc | branch: master | Pierre d'Herbemont <pdherbemont at free.fr> | Thu
> Jun  4 22:32:54 2009 -0700| [3c7efc2ecae921e52db9fea584c1405c20156c8b] |
> committer: Pierre d'Herbemont
>> -    ret = malloc( sizeof(int)*(old_depth+2) );
>> -    memcpy( ret, path, sizeof(int)*(old_depth+2) );
>> +    ret = malloc( sizeof(int) * (old_depth + 2) );
>> +    memcpy( ret, path, sizeof(int) * old_depth );
>>      ret[old_depth] = index;
> 
> In case of ENOMEM, is there anything besides segfaulting we can do here?

Depends how trivial or invasive error handling would become.

> In a related musing, would it be desirable to have a vlc_{m,c,re}alloc()
> that bails with an "out of memory" message and save some checks in
> various other parts of the code?

This is usually called xmalloc. But there is an inherent risk in providing
those. They carry an incentive to be sloppy about memory error handling. It
might be better to retain the status quo, i.e. if(!ret) abort();
explicitly...

-- 
Rémi Denis-Courmont




More information about the vlc-devel mailing list