[LV2] [PATCH 1/5] add eg05-scope example plugin

David Robillard d at drobilla.net
Tue Dec 24 08:41:32 PST 2013


On Fri, 2013-12-20 at 20:20 +0100, Robin Gareus wrote:
> On 12/15/2013 10:00 PM, David Robillard wrote:
> > On Mon, 2013-12-09 at 20:41 +0100, Robin Gareus wrote:
> > [...]
> >>  plugins/eg05-scope.lv2/examploscope_ui.c   |  629 ++++++++++++++++++++++++++++
> > 
> > There seems to be broken atom logic in this code:
> > 
> > if (/* ... */
> >     2 == lv2_atom_object_get(obj,
> >                              ui->uris.channelID, &a0,
> >                              ui->uris.audioData, &a1,
> >                              NULL)
> >     && a0->type == ui->uris.atom_Int
> >     && a1->type == ui->uris.atom_Vector) {
> >     /* ... */
> >     
> >     LV2_Atom_Vector* vof = (LV2_Atom_Vector*)LV2_ATOM_BODY(a1);
> > 
> > So, a1 is a atom_Vector, but you're casting the *body* of that atom to
> > LV2_Atom_Vector, which includes an atom header.  I think the subsequent
> > size calculation and getting of floats is incorrect and bad data is
> > being passed to the drawing functions.
> 
> Think again :) ..and if in doubt just printf() it.
> 
> The ->size of the LV2_Atom is only about the payload and does not
> include the header itself in the count. The original version was
> correct. fix attached.

Yes, you're right.  The size calculation was correct but the casts were
not.  It happened to work out that the data pointer ended up at the
right place anyway.

Thanks,

-- 
dr




More information about the Devel mailing list