Browse Source

Timeline: Fix double free of Sequence_Widget::_label.

tags/non-daw-v1.2.0
Jonathan Moore Liles 12 years ago
parent
commit
73ebd3534b
6 changed files with 12 additions and 29 deletions
  1. +0
    -3
      timeline/src/Annotation_Region.C
  2. +0
    -8
      timeline/src/Sequence_Point.C
  3. +1
    -11
      timeline/src/Sequence_Point.H
  4. +2
    -0
      timeline/src/Sequence_Widget.C
  5. +5
    -4
      timeline/src/Tempo_Point.H
  6. +4
    -3
      timeline/src/Time_Point.H

+ 0
- 3
timeline/src/Annotation_Region.C View File

@@ -67,8 +67,6 @@ Annotation_Region::Annotation_Region ( Sequence *sequence, nframes_t when, const


Annotation_Region::Annotation_Region ( const Annotation_Region &rhs ) : Sequence_Region( rhs ) Annotation_Region::Annotation_Region ( const Annotation_Region &rhs ) : Sequence_Region( rhs )
{ {
_label = strdup( rhs._label );

log_create(); log_create();
} }


@@ -76,7 +74,6 @@ Annotation_Region::Annotation_Region ( const Annotation_Region &rhs ) : Sequence
Annotation_Region::~Annotation_Region ( ) Annotation_Region::~Annotation_Region ( )
{ {
log_destroy(); log_destroy();
if ( _label ) free( _label );
} }


void void


+ 0
- 8
timeline/src/Sequence_Point.C View File

@@ -25,23 +25,15 @@


Sequence_Point::Sequence_Point ( const Sequence_Point &rhs ) : Sequence_Widget( rhs ) Sequence_Point::Sequence_Point ( const Sequence_Point &rhs ) : Sequence_Widget( rhs )
{ {
if ( rhs._label )
_label = strdup( rhs._label );
else
_label = 0;
} }


Sequence_Point::Sequence_Point ( ) Sequence_Point::Sequence_Point ( )
{ {
_label = NULL;

color( FL_CYAN ); color( FL_CYAN );
} }


Sequence_Point::~Sequence_Point ( ) Sequence_Point::~Sequence_Point ( )
{ {
if ( _label )
free( _label );
} }




+ 1
- 11
timeline/src/Sequence_Point.H View File

@@ -31,25 +31,15 @@ protected:
void get ( Log_Entry &e ) const; void get ( Log_Entry &e ) const;
void set ( Log_Entry &e ); void set ( Log_Entry &e );



virtual void draw_box ( void ); virtual void draw_box ( void );
virtual void draw ( void ); virtual void draw ( void );


Sequence_Point ( const Sequence_Point &rhs ); Sequence_Point ( const Sequence_Point &rhs );
Sequence_Point ( ); Sequence_Point ( );
~Sequence_Point ( );
virtual ~Sequence_Point ( );


public: public:


const char *label ( void ) const { return _label; }
void label ( const char *s )
{
if ( _label )
free( _label );
_label = strdup( s );
redraw();
}

Fl_Align align ( void ) const { return FL_ALIGN_RIGHT; } Fl_Align align ( void ) const { return FL_ALIGN_RIGHT; }
virtual int abs_w ( void ) const { return 8; } virtual int abs_w ( void ) const { return 8; }




+ 2
- 0
timeline/src/Sequence_Widget.C View File

@@ -59,6 +59,8 @@ Sequence_Widget::Sequence_Widget ( const Sequence_Widget &rhs ) : Loggable( rhs


if ( rhs._label ) if ( rhs._label )
_label = strdup( rhs._label ); _label = strdup( rhs._label );
else
_label = 0;


_sequence = rhs._sequence; _sequence = rhs._sequence;




+ 5
- 4
timeline/src/Tempo_Point.H View File

@@ -32,10 +32,11 @@ class Tempo_Point : public Sequence_Point
void void
_make_label ( void ) _make_label ( void )
{ {
if ( ! _label )
_label = (char*)malloc( 40 );
char l[10];


snprintf( _label, 40, "%.1f", _tempo );
snprintf( l, sizeof(l), "%.1f", _tempo );

label( l );
} }


protected: protected:
@@ -59,7 +60,7 @@ public:


Tempo_Point ( nframes_t when, float bpm ); Tempo_Point ( nframes_t when, float bpm );


~Tempo_Point ( );
virtual ~Tempo_Point ( );


Tempo_Point ( const Tempo_Point &rhs ) : Sequence_Point( rhs ) Tempo_Point ( const Tempo_Point &rhs ) : Sequence_Point( rhs )
{ {


+ 4
- 3
timeline/src/Time_Point.H View File

@@ -44,10 +44,11 @@ class Time_Point : public Sequence_Point
void void
_make_label ( void ) _make_label ( void )
{ {
if ( ! _label )
_label = (char*)malloc( 40 );
char l[10];
snprintf( l, sizeof(l), "%d/%d", _time.beats_per_bar, _time.beat_type );


snprintf( _label, 40, "%d/%d", _time.beats_per_bar, _time.beat_type );
label( l );
} }






Loading…
Cancel
Save