denemo-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Denemo-devel] midi bug


From: Richard Shann
Subject: Re: [Denemo-devel] midi bug
Date: Tue, 20 Oct 2009 21:24:35 +0100

On Tue, 2009-10-20 at 14:54 -0500, Jeremiah Benham wrote:
> Just looking at it I see a type mismatch for the variable len. It is  
> first declared an int and later typed ad a char. I don't think there  
> is an issue converting between int and char but u believe that has to  
> be an unsigned character if that is to work correctly. I am just  
> guessing here.
I think that's ok - moreover we are only at len = 48 or so here.

I noticed a function in libsmf which seems to be for putting textual
meta events, and have pushed a fix into the stable branch that uses
this, as it seems to fix the bug.
I'll put the same fix into the master shortly. Please concentrate
testing on the MIDI output - is it still good for all purposes?

Richard


> 
> Jeremiah
> 
> 
> On Oct 20, 2009, at 11:18 AM, Richard Shann <address@hidden>  
> wrote:
> 
> > There is an important bug outstanding:
> >    with instrument name "string ensemble 2" the placing of the meta  
> > event
> > into libsmf leads to a memory corruption on delete of the smf.
> > The code in exportmidi.c that emits the meta event is this:
> >
> >      /* The midi instrument */
> >           event = midi_meta_text (4,
> > curstaffstruct->midi_instrument->str);
> >       smf_track_add_event_delta_pulses(track, event, 0);
> >
> >
> > where midi_meta_text() is given below.
> > Question: Why? What is special about that string, or what other factor
> > is involved?
> > Richard
> > function definition follows:
> >
> > static smf_event_t *
> > midi_meta_text (int metatype, char *string)
> > {
> >  int len;
> >  smf_event_t *event = smf_event_new();
> >  len = strlen (string);
> >  if(len>255) {
> >    g_warning("Truncating string %s\n", string);
> >    len = 255;
> >  }
> >  gchar *buffer = (gchar*)malloc(len+3);
> >  event->midi_buffer = buffer;
> >  event->midi_buffer_length = len+3;
> >  /* meta event */
> >  *buffer++ =  0xff;
> >
> >  /* meta type */
> >  *buffer++ =  metatype;
> >
> >  /* meta size */
> >  *buffer++ = (char)len;
> >
> >  /* meta text */
> >  strncpy(buffer, string, len);
> >  *(buffer+len) = 0;
> >  return event;
> > }
> >
> >
> >
> >
> > _______________________________________________
> > Denemo-devel mailing list
> > address@hidden
> > http://lists.gnu.org/mailman/listinfo/denemo-devel





reply via email to

[Prev in Thread] Current Thread [Next in Thread]