From f81c101bcd1f000aa71673f913e1cced01a3eee2 Mon Sep 17 00:00:00 2001 From: pompolic <pompolic@special-circumstanc.es> Date: Thu, 23 Jun 2022 19:28:32 +0200 Subject: [PATCH] Don't allow initialization with address of 0x0 --- gdb-port/ast.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gdb-port/ast.py b/gdb-port/ast.py index f661cf6..ea9ccf4 100644 --- a/gdb-port/ast.py +++ b/gdb-port/ast.py @@ -4,6 +4,8 @@ class HParseResult: def __init__(self, address): # Note to self: Address has to be an integer and not string # Otherwise all hell breaks loose + if address == 0: + raise ValueError("Nullpointer given as address of HParseResult") self.address = address # Mostly for convenience self.has_ast = self.read_AST_not_null() @@ -71,6 +73,8 @@ class HParsedToken: # The former will allocate an char[] and cast it to a HParsedToken* when reading members if isinstance(address, str): print("Warning: Address % given to HParsedToken is a string. This is probably an error (expecting int or gdb.Value)" % address) + if address == 0: + raise ValueError("Nullpointer given as address of HParsedToken") self.address = address # Unused for now self.parent = parent -- GitLab