From 25357e2666ad46bb8e133884928c080c15f54956 Mon Sep 17 00:00:00 2001 From: Kelvin Sherlock Date: Wed, 31 Dec 2014 18:47:08 -0500 Subject: [PATCH] template -- check if ptr is valid --- bin/template.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/bin/template.cpp b/bin/template.cpp index b6bdee2..ff927a5 100644 --- a/bin/template.cpp +++ b/bin/template.cpp @@ -1,6 +1,7 @@ #include "template.h" #include "debugger.h" #include "debugger_internal.h" +#include "loader.h" // Flags. #include @@ -60,6 +61,12 @@ namespace Debug { } + inline bool ValidPointer(uint32_t value) + { + return value && value < Flags.memorySize; + } + + } void CreateTypedef(const std::string *name, int type, TemplateParseInfo *info) @@ -153,8 +160,7 @@ namespace Debug { case kPStringPtr: // read the string... - if (!value) return; - // need function to check if it's a valid pointer? + if (ValidPointer(value)) { std::string tmp = ReadPString(value); CleanupString(tmp); @@ -164,8 +170,7 @@ namespace Debug { case kCStringPtr: // read the string... - if (!value) return; - // need function to check if it's a valid pointer? + if (ValidPointer(value)) { std::string tmp = ReadCString(value); CleanupString(tmp);