From: Andre Noll <maan@systemlinux.org>
Date: Sun, 1 Sep 2013 15:54:25 +0000 (+0000)
Subject: vss: Avoid assertion "i == g->num_header_slices - 1".
X-Git-Tag: v0.5.1~13^2~4
X-Git-Url: https://git.tue.mpg.de/?a=commitdiff_plain;h=17a1b40b20ff584a3c4347546e419001f9bd2a63;p=paraslash.git

vss: Avoid assertion "i == g->num_header_slices - 1".

This fixes a very old bug in the timing code for fec slices. Depending
on the number of bytes to submit and on the number of slices of the
current fec group it may happen that we reserve more slices than
needed for the audio file header. This is not a problem per se, but the
above assertion hits in this case and aborts para_server.

Fix this by removing the assertion, and make sure that all reserved
header slices are properly initialized.
---

diff --git a/vss.c b/vss.c
index aec357ab..06707d6c 100644
--- a/vss.c
+++ b/vss.c
@@ -565,8 +565,14 @@ static int setup_next_fec_group(struct fec_client *fc, struct vss_task *vsst)
 		if (payload_size < g->slice_bytes)
 			memset(fc->extra_header_buf + payload_size, 0,
 				g->slice_bytes - payload_size);
-		fc->src_data[i] = fc->extra_header_buf;
-		assert(i == g->num_header_slices - 1);
+		/*
+		 * There might be more than one header slice to fill although
+		 * only the first one will be used. Set all header slices to
+		 * our extra buffer.
+		 */
+		while (i < g->num_header_slices)
+			fc->src_data[i++] = fc->extra_header_buf;
+		break; /* we don't want i to be increased. */
 	}
 
 	/*