Fix bidi-line-level-loop boundaries

The first change was caught using dynamic code analysis and prevents
access to uninitialized memory (it wouldn't be worse than that, though,
given we do not access memory we are not allowed to and the consequences
are harmless).

The second change was found by eyesight.

Signed-off-by: Laslo Hunhold <dev@frign.de>
diff --git a/src/bidirectional.c b/src/bidirectional.c
index 214b72c..4e81df1 100644
--- a/src/bidirectional.c
+++ b/src/bidirectional.c
@@ -1527,7 +1527,7 @@
 		 * we hit the end of the line but were in a run;
 		 * reset the line levels to the paragraph level
 		 */
-		for (i = runsince; i < MIN(linelen, levsize); i++) {
+		for (i = runsince; i < MIN(linelen, levlen); i++) {
 			if (get_level(lev, i) != -1) {
 				set_level(lev, i, runlevel);
 			}
@@ -1624,7 +1624,7 @@
 	 * output
 	 */
 	get_line_embedding_levels(linedata, linelen, get_level_uint32,
-	                          set_level_uint32, output, linelen, true);
+	                          set_level_uint32, output, outputsize, true);
 
 	/* determine level range */
 	for (i = 0; i < outputlen; i++) {