[outputs] Fix segv due to incorrect array size (fix for issue #866)

If the number of quality subscriptions reaches max then this bug will be
triggered, because we will incorrectly use the last element of the
output_buffer for a subscription, thus losing the zero terminator.
This commit is contained in:
ejurgensen 2019-12-27 00:10:32 +01:00
parent 33f97f55f3
commit 0c08e83811
2 changed files with 4 additions and 3 deletions

View File

@ -313,7 +313,6 @@ buffer_fill(struct output_buffer *obuf, void *buf, size_t bufsize, struct media_
int i; int i;
int n; int n;
obuf->write_counter++;
obuf->pts = *pts; obuf->pts = *pts;
// The resampling/encoding (transcode) contexts work for a given input quality, // The resampling/encoding (transcode) contexts work for a given input quality,

View File

@ -187,9 +187,11 @@ struct output_data
struct output_buffer struct output_buffer
{ {
uint32_t write_counter; // REMOVE ME? not used for anything
struct timespec pts; struct timespec pts;
struct output_data data[OUTPUTS_MAX_QUALITY_SUBSCRIPTIONS + 1]; // The array is two larger than max quality subscriptions because element 0
// holds the original, untranscoded, data (which might not have any
// subscribers, and the last element is a zero terminator.
struct output_data data[OUTPUTS_MAX_QUALITY_SUBSCRIPTIONS + 2];
} output_buffer; } output_buffer;
struct output_definition struct output_definition