From 9737c0c4dd40e5db535644151e889ebec1249a71 Mon Sep 17 00:00:00 2001 From: david Date: Fri, 28 Jun 2002 16:56:14 +0000 Subject: [PATCH] Fixed bug reported by Julian Foad: While investigating, I found that SGPropertyNode::getPath returns a (char *) pointer to the character data of a string on its stack, i.e. to undefined memory after it returns. I remember someone was changing strings to char* for efficiency. Perhaps this bug was introduced then. I'll include a patch for it with my eventual patch for the above, unless someone beats me to it. I don't think it affects any existing callers: they all want a string anyway. --- simgear/misc/props.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/simgear/misc/props.cxx b/simgear/misc/props.cxx index bb137124..cb721d34 100644 --- a/simgear/misc/props.cxx +++ b/simgear/misc/props.cxx @@ -931,7 +931,8 @@ SGPropertyNode::getPath (bool simplify) const sprintf(buffer, "[%d]", _index); path += buffer; } - return path.c_str(); + strncpy(_buffer, path.c_str(), MAX_STRING_LEN); + return _buffer; } SGPropertyNode::Type -- 2.39.5