[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[developers] Valgrind bug in minibidi.c



Hello, 
I would like to submit a bug and a possible patch. I discovered the bug
with Valgrind.

In minibidi.c, in function "flipThisRun" , level[i] was read while
testing its value, even if i was out of range. Switching the tests
resolves the problem.

Always in minibidi.c, "doBidi" . levels[i] was read when "i" was out of
range (i=count).

Also, "tempType = levels[j];" was not used.

Please let me know if you agree with this modifications.

Regards.

==patch==

diff --git a/src/minibidi.c b/src/minibidi.c
index d64501f..584bffc 100644
--- a/src/minibidi.c
+++ b/src/minibidi.c
@@ -98,7 +98,7 @@ void flipThisRun(BLOCKTYPE from, unsigned char* level,
int max, int count)
       tlevel = max;
       i = j = findIndexOfRun(level, i, count, max);
       /* find the end of the run */
-      while((tlevel <= level[i]) && (i < count))
+      while((i < count)&&(tlevel <= level[i]))
       {
         i++;
       }
@@ -1461,11 +1461,9 @@ int doBidi(BLOCKTYPE line, int count, int
applyShape, int reorderCombining)
                 {
                   tempType = levels[j];
                   i=j;
-                  while((i++ < count) && (levels[i] == tempType));
+                  while((++i < count) && (levels[i] == tempType));
                   doShape(line, shapeTo, j, i);
                   j=i;
-                  tempType = levels[j];
-                  
                 }
             }
           j++;




-- 
Pierre Vullo
os4i.com