Skip to content

Commit

Permalink
Fix possible array index crashes in multitrack and transition.
Browse files Browse the repository at this point in the history
Reported by JBM.
  • Loading branch information
ddennedy committed Jan 13, 2016
1 parent 8d6817d commit dd12f73
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 3 additions & 3 deletions src/framework/mlt_multitrack.c
Expand Up @@ -3,7 +3,7 @@
* \brief multitrack service class
* \see mlt_multitrack_s
*
* Copyright (C) 2003-2015 Meltytech, LLC
* Copyright (C) 2003-2016 Meltytech, LLC
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -364,7 +364,7 @@ mlt_producer mlt_multitrack_track( mlt_multitrack self, int track )
{
mlt_producer producer = NULL;

if ( self->list != NULL && track < self->count )
if ( self->list != NULL && track >= 0 && track < self->count )
producer = self->list[ track ]->producer;

return producer;
Expand Down Expand Up @@ -548,7 +548,7 @@ static int producer_get_frame( mlt_producer parent, mlt_frame_ptr frame, int ind
mlt_multitrack self = parent->child;

// Check if we have a track for this index
if ( index < self->count && self->list[ index ] != NULL )
if ( index >= 0 && index < self->count && self->list[ index ] != NULL )
{
// Get the producer for this track
mlt_producer producer = self->list[ index ]->producer;
Expand Down
4 changes: 3 additions & 1 deletion src/framework/mlt_transition.c
Expand Up @@ -3,7 +3,7 @@
* \brief abstraction for all transition services
* \see mlt_transition_s
*
* Copyright (C) 2003-2015 Meltytech, LLC
* Copyright (C) 2003-2016 Meltytech, LLC
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
Expand Down Expand Up @@ -427,6 +427,8 @@ static int transition_get_frame( mlt_service service, mlt_frame_ptr frame, int i
a_track = b_track;
b_track = mlt_properties_get_int( properties, "a_track" );
}
a_track = a_track < 0 ? 0 : a_track;
b_track = b_track < 0 ? 0 : b_track;

// Only act on this operation once per multitrack iteration from the tractor
if ( !self->held )
Expand Down

0 comments on commit dd12f73

Please sign in to comment.