[vlc-devel] [PATCH] darwin/dirs: validate rc of asprint()

Rémi Denis-Courmont remi at remlab.net
Sat Apr 25 21:56:18 CEST 2015


Le samedi 25 avril 2015, 09:33:17 David Fuhrmann a écrit :
> Hello,
> 
> > Am 25.04.2015 um 02:09 schrieb Arjun Sreedharan <arjun024 at gmail.com>:
> > 
> > When asprintf() fails, @path is undefined.
> > 
> > Signed-off-by: Arjun Sreedharan <arjun024 at gmail.com>
> > ---
> > src/darwin/dirs.c | 5 +++--
> > 1 file changed, 3 insertions(+), 2 deletions(-)
> > 
> > diff --git a/src/darwin/dirs.c b/src/darwin/dirs.c
> > index 9c34cc5..7b6cedf 100644
> > --- a/src/darwin/dirs.c
> > +++ b/src/darwin/dirs.c
> > @@ -82,9 +82,10 @@ char *config_GetLibDir (void)
> > 
> >     if (dladdr(system_Init, &info)) {
> >     
> >         char *incompletepath = strdup(dirname( (char *)info.dli_fname ));
> >         char *path = NULL;
> > 
> > -        asprintf(&path, "%s/"PACKAGE, incompletepath);
> > +        if(asprintf(&path, "%s/"PACKAGE, incompletepath) == -1)
> > +            path = NULL;
> 
> This is not needed. path is already NULL on error.

Does Darwin implement the FreeBSD semantics? FreeBSD sets the pointer to NULL 
on error, but GNU/Linux does _not_. The function is not in any standard.

And yeah, this is a Darwin-specific code path.

-- 
Rémi Denis-Courmont
http://www.remlab.net/




More information about the vlc-devel mailing list