From f4b424cd539eed26de18e81fd9d433cd6ae6295b Mon Sep 17 00:00:00 2001 From: Steve Reinhardt Date: Mon, 6 Aug 2012 16:57:11 -0700 Subject: [PATCH] SETranslatingPortProxy: fix bug in tryReadString() Off-by-one loop termination meant that we were stuffing the terminating '\0' into the std::string value, which makes for difficult-to-debug string comparison failures. --- src/mem/se_translating_port_proxy.cc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/mem/se_translating_port_proxy.cc b/src/mem/se_translating_port_proxy.cc index 72466655c..7857217f6 100644 --- a/src/mem/se_translating_port_proxy.cc +++ b/src/mem/se_translating_port_proxy.cc @@ -190,15 +190,18 @@ SETranslatingPortProxy::tryReadString(std::string &str, Addr addr) const Addr vaddr = addr; - do { + while (true) { Addr paddr; if (!pTable->translate(vaddr++, paddr)) return false; PortProxy::readBlob(paddr, &c, 1); + if (c == '\0') + break; + str += c; - } while (c); + } return true; } -- 2.30.2