[vlc-devel] [vlc-commits] strings: use vlc_memstream in vlc_xml_encode()

Rémi Denis-Courmont remi at remlab.net
Sat Feb 25 09:11:11 CET 2017


Le perjantaina 24. helmikuuta 2017, 21.32.55 EET Filip Roséen a écrit :
> Hi Rémi,
> 
> On 2017-02-24 21:01, Rémi Denis-Courmont wrote:
> > vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri Feb 24
> > 22:01:38 2017 +0200| [7641dfe3eabcd7c3f1c2ae56cac3ed98b099d892] |
> > committer: Rémi Denis-Courmont
> > 
> > strings: use vlc_memstream in vlc_xml_encode()
> > 
> > > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=7641dfe3eabcd7c3f
> > > 1c2ae56cac3ed98b099d892> 
> > ---
> > 
> >  src/text/strings.c | 45 ++++++++++++++++++++++++++-------------------
> >  1 file changed, 26 insertions(+), 19 deletions(-)
> > 
> > diff --git a/src/text/strings.c b/src/text/strings.c
> > index edc8834..45d72a1 100644
> > --- a/src/text/strings.c
> > +++ b/src/text/strings.c
> > @@ -284,38 +284,46 @@ void vlc_xml_decode( char *psz_value )
> > 
> >  char *vlc_xml_encode (const char *str)
> >  {
> > 
> > -    assert (str != NULL);
> > -
> > -    const size_t len = strlen (str);
> > -    char *const buf = malloc (6 * len + 1), *ptr = buf;
> > -    if (unlikely(buf == NULL))
> > -        return NULL;
> > -
> > +    struct vlc_memstream stream;
> > 
> >      size_t n;
> >      uint32_t cp;
> > 
> > +    assert(str != NULL);
> > +    vlc_memstream_open(&stream);
> 
> Missing check to see if `vlc_memstream_open` actually created a valid
> handle.

No. It is, by design, safe to ignore vlc_memstream_open() failure. Otherwise, 
I´d have marked it VLC_USED.

-- 
雷米‧德尼-库尔蒙
https://www.remlab.net/



More information about the vlc-devel mailing list