[Spice-devel] [PATCH spice-server 2/3] test-gst: Remove options parsing leaks

Christophe Fergeau cfergeau at redhat.com
Tue Sep 12 08:07:52 UTC 2017


On Tue, Sep 12, 2017 at 03:41:15AM -0400, Frediano Ziglio wrote:
> > 
> > On Tue, Sep 12, 2017 at 03:19:12AM -0400, Frediano Ziglio wrote:
> > > > > -    const EncoderInfo *encoder = get_encoder_info(encoder_name);
> > > > > +    const EncoderInfo *encoder = get_encoder_info(encoder_name ?
> > > > > encoder_name : "mjpeg");
> > > > >      if (!encoder) {
> > > > >          g_printerr("Encoder name unsupported: %s\n", encoder_name);
> > > > 
> > > > This is going to be "Encoder name unsupported: (null)" when the
> > > > corresponding option is not given, ditto for the other options that you
> > > > changed.
> > > > 
> > > 
> > > No, the defaults are present so encoder won't be NULL... but I can change
> > > the code to make this more clear.
> > 
> > I'm missing something then, the code I quoted is:
> > 
> >      const EncoderInfo *encoder = get_encoder_info(encoder_name ?
> >      encoder_name : "mjpeg");
> >      if (!encoder) {
> >           g_printerr("Encoder name unsupported: %s\n", encoder_name);
> > 
> > so it looks like encoder_name can be NULL in the call to
> > get_encoder_info(), in which case we call get_encoder_info("mjpeg")
> > instead of get_encoder_info(encoder_name), but right after that, in the
> > g_printerr call, encoder_name cannot be NULL?
> > 
> 
> No, get_encoder_info("mjpeg") is not supposed to return NULL... but I changed
> the code to understand it even without reading get_encoder_info, better.

But you are printing "encoder_name" (the input parameter), not "encoder" (the output) !

Christophe


More information about the Spice-devel mailing list