[Spice-devel] [PATCH spice v2 2/2] Do not crash on NULL codecs
Pavel Grunt
pgrunt at redhat.com
Wed Nov 16 14:03:50 UTC 2016
On Wed, 2016-11-16 at 08:51 -0500, Frediano Ziglio wrote:
> > On Wed, 2016-11-16 at 06:21 -0500, Frediano Ziglio wrote:
> > > >
> > > > On Wed, Nov 16, 2016 at 10:10:01AM +0100, Pavel Grunt wrote:
> > > > > ---
> > > > > server/reds.c | 2 +-
> > > > > server/tests/spice-codecs-parsing-test.c | 1 +
> > > > > 2 files changed, 2 insertions(+), 1 deletion(-)
> > > > >
> > > > > diff --git a/server/reds.c b/server/reds.c
> > > > > index 12a274c..eccc2ba 100644
> > > > > --- a/server/reds.c
> > > > > +++ b/server/reds.c
> > > > > @@ -3639,7 +3639,7 @@ static void
> > > > > reds_set_video_codecs(RedsState *reds,
> > > > > const char *codecs)
> > > > > {
> > > > > char *encoder_name, *codec_name;
> > > > >
> > > > > - if (strcmp(codecs, "auto") == 0) {
> > > > > + if (codecs == NULL || strcmp(codecs, "auto") == 0) {
> > > > > codecs = default_video_codecs;
> > > >
> > > > Or just if (g_strcmp0(codecs, "auto") == 0) {}
> > > >
> > > >
> > > > Acked-by: Christophe Fergeau <cfergeau at redhat.com>
> > > >
> > >
> > > What's the reason to allows NULL ?
> > > Personally I would nack this patch.
> >
> > As the shortlog says - to avoid crashing. I can change it to
> > g_return...
> >
> > Pavel
> >
>
> I honestly prefer the crash.
Then it is not undefined behavior but 100% crash. IMO library should
not crash a program...
Pavel
>
> Frediano
More information about the Spice-devel
mailing list