[FFmpeg-devel] [PATCH 14/14] avutil/avstring: Avoid av_strdup(NULL)

Vittorio Giovara vittorio.giovara at gmail.com
Mon Mar 25 20:15:16 EET 2024


On Mon, Mar 25, 2024 at 12:55 PM Andreas Rheinhardt <
andreas.rheinhardt at outlook.com> wrote:

> Vittorio Giovara:
> > On Mon, Mar 25, 2024 at 12:38 PM Andreas Rheinhardt <
> > andreas.rheinhardt at outlook.com> wrote:
> >
> >> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> >> ---
> >>  libavutil/avstring.c | 2 +-
> >>  1 file changed, 1 insertion(+), 1 deletion(-)
> >>
> >> diff --git a/libavutil/avstring.c b/libavutil/avstring.c
> >> index 2071dd36a5..8702fe0455 100644
> >> --- a/libavutil/avstring.c
> >> +++ b/libavutil/avstring.c
> >> @@ -299,7 +299,7 @@ char *av_append_path_component(const char *path,
> const
> >> char *component)
> >>      char *fullpath;
> >>
> >>      if (!path)
> >> -        return av_strdup(component);
> >> +        return component ? av_strdup(component) : NULL;
> >>      if (!component)
> >>          return av_strdup(path);
> >>
> >
> > isn't this what av_strdup already does?
>
> It's not documented to do so. It could also decide to treat
> av_strdup(NULL) as av_strdup("").
>

Ah fair point, but should we not update its documentation instead?
-- 
Vittorio


More information about the ffmpeg-devel mailing list