From e73707886cb068a09eeac41bf450cb15e2e01c8f Mon Sep 17 00:00:00 2001
From: pompolic <pompolic@special-circumstanc.es>
Date: Fri, 21 Oct 2022 14:42:42 +0200
Subject: [PATCH] Move check for 0 width before iterating over input_token_map

---
 gdb-port/top-level-parse.py | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gdb-port/top-level-parse.py b/gdb-port/top-level-parse.py
index 0a33445..7db8519 100644
--- a/gdb-port/top-level-parse.py
+++ b/gdb-port/top-level-parse.py
@@ -399,13 +399,13 @@ class TopLevelParse:
 	# TODO: remove first printing loop
 	def print_input_chunk(self, token, rows, start, end):
 		#print("print_input_chunk(): start: ", start, "end: ", end)
-		tokenmap_val_list = [dict(token, addr=hex(key)) for key, token in self.input_token_map.items() if (token['start'] >= start and token['start'] <= end)]
-		numrows = min(rows, len(tokenmap_val_list))
-		h = numrows
 		w = end-start
 		if w == 0:
 			print("all tokens passed to display are zero-width")
 			return
+		tokenmap_val_list = [dict(token, addr=hex(key)) for key, token in self.input_token_map.items() if (token['start'] >= start and token['start'] <= end)]
+		numrows = min(rows, len(tokenmap_val_list))
+		h = numrows
 
 		# Print by getting a token, and recursively walking its children if applicable
 		charbuf = [[' '] * w for i in range(0,h)]
-- 
GitLab