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() ...@@ -110,7 +110,7 @@ IRenderer::~IRenderer()
void IRenderer::addRenderObject(ACG::RenderObject* _renderObject) void IRenderer::addRenderObject(ACG::RenderObject* _renderObject)
{ {
// avoid null-ptr access // avoid null-ptr access
if (!_renderObject->debugName) if (_renderObject->debugName.empty())
_renderObject->debugName = "<unnamed>"; _renderObject->debugName = "<unnamed>";
if (_renderObject->name.empty()) if (_renderObject->name.empty())
......
...@@ -233,7 +233,7 @@ RenderObject::RenderObject() ...@@ -233,7 +233,7 @@ RenderObject::RenderObject()
inZPrePass(true), inZPrePass(true),
depthMapUniformName(0), depthMapUniformName(0),
debugID(0), debugName(0), debugID(0),
internalFlags_(0) internalFlags_(0)
{ {
colorWriteMask[0] = colorWriteMask[1] = colorWriteMask[2] = colorWriteMask[3] = 1; colorWriteMask[0] = colorWriteMask[1] = colorWriteMask[2] = colorWriteMask[3] = 1;
...@@ -297,7 +297,7 @@ QString RenderObject::toString() const ...@@ -297,7 +297,7 @@ QString RenderObject::toString() const
const GLenum maxSupportedPrimitiveMode = GL_PATCHES; const GLenum maxSupportedPrimitiveMode = GL_PATCHES;
#endif #endif
resultStrm << "name: " << debugName resultStrm << "name: " << QString::fromStdString(debugName)
<< "\ndebugID: " << debugID << "\ndebugID: " << debugID
<< "\npriority: " << priority << "\npriority: " << priority
<< "\nprimitiveMode: " << (primitiveMode <= maxSupportedPrimitiveMode ? primitiveString[primitiveMode] : "undefined") << "\nprimitiveMode: " << (primitiveMode <= maxSupportedPrimitiveMode ? primitiveString[primitiveMode] : "undefined")
......
...@@ -365,7 +365,7 @@ public: ...@@ -365,7 +365,7 @@ public:
/// used internally for renderer debugging /// used internally for renderer debugging
int debugID; int debugID;
const char* debugName; std::string debugName;
/// may be used internally by the renderer /// may be used internally by the renderer
unsigned int internalFlags_; unsigned int internalFlags_;
......
...@@ -454,7 +454,7 @@ getRenderObjects(IRenderer* _renderer, GLState& _state , const DrawModes::DrawM ...@@ -454,7 +454,7 @@ getRenderObjects(IRenderer* _renderer, GLState& _state , const DrawModes::DrawM
case SPHERE: case SPHERE:
// 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); sphere_->addToRenderer(_renderer, &ro, primitives_[i].size);
......
...@@ -559,7 +559,7 @@ getRenderObjects(IRenderer* _renderer, GLState& _state , const DrawModes::DrawM ...@@ -559,7 +559,7 @@ getRenderObjects(IRenderer* _renderer, GLState& _state , const DrawModes::DrawM
ro.setMaterial(_mat); ro.setMaterial(_mat);
lineNodeName_ = std::string("LineNode: ")+name(); lineNodeName_ = std::string("LineNode: ")+name();
ro.debugName = lineNodeName_.c_str(); ro.debugName = lineNodeName_;
// draw after scene-meshes // draw after scene-meshes
if (draw_always_on_top) if (draw_always_on_top)
......
...@@ -1054,7 +1054,7 @@ void PrincipalAxisNode::getRenderObjects(IRenderer* _renderer, GLState& _state, ...@@ -1054,7 +1054,7 @@ void PrincipalAxisNode::getRenderObjects(IRenderer* _renderer, GLState& _state,
ro.setMaterial(_mat); ro.setMaterial(_mat);
nodeName_ = std::string("PrincipalAxisNode: ") + name(); nodeName_ = std::string("PrincipalAxisNode: ") + name();
ro.debugName = nodeName_.c_str(); ro.debugName = nodeName_;
ro.depthTest = true; ro.depthTest = true;
ro.depthWrite = true; ro.depthWrite = true;
......
...@@ -592,7 +592,7 @@ getRenderObjects(ACG::IRenderer* _renderer, ACG::GLState& _state , const ACG::S ...@@ -592,7 +592,7 @@ getRenderObjects(ACG::IRenderer* _renderer, ACG::GLState& _state , const ACG::S
ro.initFromState(&_state); 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 // do not rotate the quads in this case
if (textMode_ == SCREEN_ALIGNED || textMode_ == SCREEN_ALIGNED_STATIC_SIZE) 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