[Spice-devel] [vdagent-win PATCH v8 4/5] Support encoding PNG images

Christophe Fergeau cfergeau at redhat.com
Fri Jul 21 13:18:25 UTC 2017


On Fri, Jul 21, 2017 at 09:13:26AM -0400, Frediano Ziglio wrote:
> > 
> > On Wed, Jul 19, 2017 at 09:42:42AM +0100, Frediano Ziglio wrote:
> > > -uint8_t *PngCoder::from_bitmap(const BITMAPINFO& info, const void *bits,
> > > long &size)
> > > +uint8_t *PngCoder::from_bitmap(const BITMAPINFO& bmp_info, const void
> > > *bits, long &size)
> > >  {
> > > -    // TODO not implemented
> > > -    return NULL;
> > > +    // this vector is here to avoid problems as libpng use setjmp/longjmp
> > 
> > Nit: I'd be more specific about the problems you are avoiding, as the
> > goal of this comment is that someone changing this code is not going to
> > be careful and not introduce the issues you had in mind.
> > 
> 
> Well, is tricky as the safe usage of setjmp/longjmp.
> 
> Something like
> 
> if (setjmp(jbuf)) {
> 
> }
> ...
> char *buf = malloc(100);
> ...
> longjmp(jbuf);
> 
> the jump will likely to cause a leak of buf.
> 
> In case of C++ to avoid not calling the destructor when longjmp is used
> 
> Could be
> 
>    // this vector is here to avoid leaking resources if libpng use setjmp/longjmp
> 
> ??

Perfect! I thought this was what you meant, but usually when I start
guessing, the other person was thinking of something entirely different
:)

Christophe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/spice-devel/attachments/20170721/301eec1b/attachment.sig>


More information about the Spice-devel mailing list