From c4e8908c8e267c1e93fd7fa0c9df22f474ec47f3 Mon Sep 17 00:00:00 2001 From: Jon Siwek Date: Thu, 29 Aug 2013 15:50:46 -0500 Subject: [PATCH] Fix invalid pointer dereference in AsciiFormatter. Using a temporary object with strtol() makes the end pointer that it sets invalid after the call. --- src/threading/AsciiFormatter.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/threading/AsciiFormatter.cc b/src/threading/AsciiFormatter.cc index cb1c57f6f1..616abbe2b6 100644 --- a/src/threading/AsciiFormatter.cc +++ b/src/threading/AsciiFormatter.cc @@ -247,7 +247,8 @@ threading::Value* AsciiFormatter::ParseValue(string s, string name, TypeTag type goto parse_error; } - uint8_t width = (uint8_t) strtol(s.substr(pos+1).c_str(), &end, 10); + string width_str = s.substr(pos + 1); + uint8_t width = (uint8_t) strtol(width_str.c_str(), &end, 10); if ( CheckNumberError(s, end) ) goto parse_error;