From 2c7e1c63e601ead0098929c62c582a650907b586 Mon Sep 17 00:00:00 2001
From: Cyrille Bagard <nocbos@gmail.com>
Date: Sun, 17 Jun 2018 15:12:08 +0200
Subject: Skipped labels when computing limits of routines.

---
 src/analysis/disass/routines.c | 25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/src/analysis/disass/routines.c b/src/analysis/disass/routines.c
index b1bc8c8..a0f756c 100644
--- a/src/analysis/disass/routines.c
+++ b/src/analysis/disass/routines.c
@@ -278,26 +278,39 @@ static void g_routines_study_process(GRoutinesStudy *study, GtkStatusStack *stat
 void g_routines_study_compute_limits(GRoutinesStudy *study, GBinRoutine *routine, size_t index)
 {
     GBinSymbol *symbol;                     /* Version alternative         */
+    const vmpa2t *next;                     /* Début de la zone suivante   */
     GBinSymbol *next_symbol;                /* Eventuel symbole suivant    */
     const mrange_t *range;                  /* Zone du symbole suivant     */
-    const vmpa2t *next;                     /* Début de la zone suivante   */
+    vmpa2t _next;                           /* Emplacement de zone         */
 
     symbol = G_BIN_SYMBOL(routine);
 
-    if ((index + 1) < study->count)
+    for (next = NULL, index++; next == NULL && index < study->count; index++)
     {
         next_symbol = g_binary_format_get_symbol(study->format, index + 1);
 
+        /**
+         * Les étiquettes à l'intérieur de code ne doivent pas constituer
+         * une profonde coupure à l'intérieur d'une routine.
+         *
+         * On recherche donc la fin de la routine courante via les
+         * symboles suivants.
+         */
+
+        if (g_binary_symbol_get_target_type(next_symbol) == STP_CODE_LABEL)
+            goto skip_symbol;
+
         range = g_binary_symbol_get_range(next_symbol);
-        next = get_mrange_addr(range);
+
+        copy_vmpa(&_next, get_mrange_addr(range));
+        next = &_next;
+
+ skip_symbol:
 
         g_object_unref(G_OBJECT(next_symbol));
 
     }
 
-    else
-        next = NULL;
-
     compute_routine_limit(symbol, next, study->proc, study->portions);
 
 }
-- 
cgit v0.11.2-87-g4458