From 11c911eaf1107333aef93eaeabe67957471740a6 Mon Sep 17 00:00:00 2001 From: Charles Fol Date: Fri, 13 Sep 2024 10:10:12 +0200 Subject: [PATCH] Fix history crash (#2429) * Fixed bug where history() crashes due to an history line with no command * Added extra space in history() --- pwndbg/dbg/gdb.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/pwndbg/dbg/gdb.py b/pwndbg/dbg/gdb.py index 80a009355..c88af24f0 100644 --- a/pwndbg/dbg/gdb.py +++ b/pwndbg/dbg/gdb.py @@ -1050,7 +1050,13 @@ class GDB(pwndbg.dbg_mod.Debugger): parsed_lines = [] for line in lines: - number_str, command = line.split(maxsplit=1) + try: + number_str, command = line.split(maxsplit=1) + except ValueError: + # In rare cases GDB stores a number with no command, and the split() + # then only returns one element. We can safely ignore these. + continue + try: number = int(number_str) except ValueError: