[vlc-devel] [PATCH 3/3] Initialize title strings with non NULL pointer
thomas at gllm.fr
Mon Jul 20 08:33:01 CEST 2020
On Sat, Jul 18, 2020, at 12:47, Daniel Glaas wrote:
> In principle, looking over all possible use cases of strdup I agree that
> there might be case where strdup() returns NULL. But here I used it with
> an empty string as parameter, meaning that malloc() only needs to
> allocate one single byte in the memory. If this really fails, then there
> are other problems than only a wrong display of an RSS text overlay.
We require all allocations to be checked and handled. This is not the case for every C programs and libs, but it is in VLC.
> I also tried to add catches to the NULL pointers at those places where
> they are used. But in my opinion, this makes the places of usage very
> bad to read with a lot of NULL checks at various places. A lot of places
> in the *Filter() function rely on valid pointers where the titles are
I see 2 other choices :
- fix psz_title NULLITY check everywhere
- Assign it to a special static const string (likely "") : in that case, you should check that the pointer is not equals to this special string pointer before freeing it.
Also, your patch seems to leak the "" allocation when psz_title is replaced by a new string.
> Am 18.07.20 um 09:41 schrieb Rémi Denis-Courmont:
> > Le lauantaina 18. heinäkuuta 2020, 5.07.00 EEST Daniel Glaas a écrit :
> >> Initialize title strings with non NULL pointer
> >> If no valid title could be parsed out of an RSS feed, the segmentation fault
> >> caused VLC to crash. The reason therefore was that the expected pointers to
> >> the char buffers containing the titles were NULL pointers.
> > This won't work because strdup() can return NULL. Better handle the NULL
> > values correctly.
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
More information about the vlc-devel