commit a17b629bb30ac9c0e3e7343449dc42085bb2fc59
Author:     Laslo Hunhold <[email protected]>
AuthorDate: Mon May 29 10:34:37 2023 +0200
Commit:     Laslo Hunhold <[email protected]>
CommitDate: Mon May 29 10:34:37 2023 +0200

    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 <[email protected]>

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 @@ get_line_embedding_levels(const uint_least32_t *linedata, 
size_t linelen,
                 * 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 @@ grapheme_bidirectional_reorder_line(const uint_least32_t 
*line,
         * 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++) {

Reply via email to