From b6427496bde6f3ab34dc62d6b437c4f8a3a29b2d Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Mon, 3 Oct 2016 00:40:21 +0200
Subject: Computed block ranks without mistake.

---
 ChangeLog                  | 5 +++++
 src/analysis/disass/rank.c | 5 +++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 9024665..5b4444d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,10 @@
 16-10-03  Cyrille Bagard <nocbos@gmail.com>
 
+	* src/analysis/disass/rank.c:
+	Compute block ranks without mistake.
+
+16-10-03  Cyrille Bagard <nocbos@gmail.com>
+
 	* src/common/sort.c:
 	Give more flexibility to qinsert() for the inserted item.
 
diff --git a/src/analysis/disass/rank.c b/src/analysis/disass/rank.c
index 3694d04..0b9068b 100644
--- a/src/analysis/disass/rank.c
+++ b/src/analysis/disass/rank.c
@@ -341,9 +341,9 @@ void rank_routine_block(const GBlockList *list, GBasicBlock *block)
         {
             rank = g_basic_block_get_rank(target);
 
-            if (next > rank)
+            if (next > rank || rank == -1)
             {
-                g_basic_block_set_rank(target, rank);
+                g_basic_block_set_rank(target, next);
 
                 rank_routine_block(list, target);
 
@@ -381,6 +381,7 @@ void rank_routine_blocks(GBinRoutine *routine)
     assert(start != NULL);
 
 
+    g_basic_block_set_rank(start, 0);
 
 
     rank_routine_block(blocks, start);
-- 
cgit v0.11.2-87-g4458