Commit ac325cfc authored by Jan Möbius's avatar Jan Möbius

Merge branch 'fix-RO-debugName-UAFs' into 'master'

RenderObject debug_name was a char* that sometimes pointed to temporary buffers,…

See merge request !108
parents 9b8dfec0 51a18b3e
......@@ -110,7 +110,7 @@ IRenderer::~IRenderer()
void IRenderer::addRenderObject(ACG::RenderObject* _renderObject)
{
// avoid null-ptr access
if (!_renderObject->debugName)
if (_renderObject->debugName.empty())
_renderObject->debugName = "<unnamed>";
if (_renderObject->name.empty())
......
......@@ -233,7 +233,7 @@ RenderObject::RenderObject()
inZPrePass(true),
depthMapUniformName(0),
debugID(0), debugName(0),
debugID(0),
internalFlags_(0)
{
colorWriteMask[0] = colorWriteMask[1] = colorWriteMask[2] = colorWriteMask[3] = 1;
......@@ -297,7 +297,7 @@ QString RenderObject::toString() const
const GLenum maxSupportedPrimitiveMode = GL_PATCHES;
#endif
resultStrm << "name: " << debugName
resultStrm << "name: " << QString::fromStdString(debugName)
<< "\ndebugID: " << debugID
<< "\npriority: " << priority
<< "\nprimitiveMode: " << (primitiveMode <= maxSupportedPrimitiveMode ? primitiveString[primitiveMode] : "undefined")
......
......@@ -365,7 +365,7 @@ public:
/// used internally for renderer debugging
int debugID;
const char* debugName;
std::string debugName;
/// may be used internally by the renderer
unsigned int internalFlags_;
......
......@@ -454,7 +454,7 @@ getRenderObjects(IRenderer* _renderer, GLState& _state , const DrawModes::DrawM
case SPHERE:
// Sphere
ro.debugName = (QString("glutprimitive.sphere no %1: ").arg(i)+QString(name().c_str())).toLatin1();
ro.debugName = std::string("glutprimitive.sphere no ") + std::to_string(i) + ": " + name();
sphere_->addToRenderer(_renderer, &ro, primitives_[i].size);
......
......@@ -559,7 +559,7 @@ getRenderObjects(IRenderer* _renderer, GLState& _state , const DrawModes::DrawM
ro.setMaterial(_mat);
lineNodeName_ = std::string("LineNode: ")+name();
ro.debugName = lineNodeName_.c_str();
ro.debugName = lineNodeName_;
// draw after scene-meshes
if (draw_always_on_top)
......
......@@ -1054,7 +1054,7 @@ void PrincipalAxisNode::getRenderObjects(IRenderer* _renderer, GLState& _state,
ro.setMaterial(_mat);
nodeName_ = std::string("PrincipalAxisNode: ") + name();
ro.debugName = nodeName_.c_str();
ro.debugName = nodeName_;
ro.depthTest = true;
ro.depthWrite = true;
......
......@@ -592,7 +592,7 @@ getRenderObjects(ACG::IRenderer* _renderer, ACG::GLState& _state , const ACG::S
ro.initFromState(&_state);
ro.debugName = (std::string("TextNode: ")+name()).c_str();
ro.debugName = std::string("TextNode: ")+name();
// do not rotate the quads in this case
if (textMode_ == SCREEN_ALIGNED || textMode_ == SCREEN_ALIGNED_STATIC_SIZE)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment