mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 04:41:05 +08:00
Prevent crash when setting empty uniform array
The root of the problem is accessing the first element of an empty array which reads out-of-bounds memory.
This commit is contained in:
parent
779b963530
commit
2a4ca6e053
@ -603,7 +603,7 @@ void Shader::setUniformArray(const std::string& name, const Glsl::Vec2* vectorAr
|
|||||||
|
|
||||||
UniformBinder binder(*this, name);
|
UniformBinder binder(*this, name);
|
||||||
if (binder.location != -1)
|
if (binder.location != -1)
|
||||||
glCheck(GLEXT_glUniform2fv(binder.location, static_cast<GLsizei>(length), &contiguous[0]));
|
glCheck(GLEXT_glUniform2fv(binder.location, static_cast<GLsizei>(length), !contiguous.empty() ? &contiguous[0] : NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -614,7 +614,7 @@ void Shader::setUniformArray(const std::string& name, const Glsl::Vec3* vectorAr
|
|||||||
|
|
||||||
UniformBinder binder(*this, name);
|
UniformBinder binder(*this, name);
|
||||||
if (binder.location != -1)
|
if (binder.location != -1)
|
||||||
glCheck(GLEXT_glUniform3fv(binder.location, static_cast<GLsizei>(length), &contiguous[0]));
|
glCheck(GLEXT_glUniform3fv(binder.location, static_cast<GLsizei>(length), !contiguous.empty() ? &contiguous[0] : NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -625,7 +625,7 @@ void Shader::setUniformArray(const std::string& name, const Glsl::Vec4* vectorAr
|
|||||||
|
|
||||||
UniformBinder binder(*this, name);
|
UniformBinder binder(*this, name);
|
||||||
if (binder.location != -1)
|
if (binder.location != -1)
|
||||||
glCheck(GLEXT_glUniform4fv(binder.location, static_cast<GLsizei>(length), &contiguous[0]));
|
glCheck(GLEXT_glUniform4fv(binder.location, static_cast<GLsizei>(length), !contiguous.empty() ? &contiguous[0] : NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -640,7 +640,7 @@ void Shader::setUniformArray(const std::string& name, const Glsl::Mat3* matrixAr
|
|||||||
|
|
||||||
UniformBinder binder(*this, name);
|
UniformBinder binder(*this, name);
|
||||||
if (binder.location != -1)
|
if (binder.location != -1)
|
||||||
glCheck(GLEXT_glUniformMatrix3fv(binder.location, static_cast<GLsizei>(length), GL_FALSE, &contiguous[0]));
|
glCheck(GLEXT_glUniformMatrix3fv(binder.location, static_cast<GLsizei>(length), GL_FALSE, !contiguous.empty() ? &contiguous[0] : NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -655,7 +655,7 @@ void Shader::setUniformArray(const std::string& name, const Glsl::Mat4* matrixAr
|
|||||||
|
|
||||||
UniformBinder binder(*this, name);
|
UniformBinder binder(*this, name);
|
||||||
if (binder.location != -1)
|
if (binder.location != -1)
|
||||||
glCheck(GLEXT_glUniformMatrix4fv(binder.location, static_cast<GLsizei>(length), GL_FALSE, &contiguous[0]));
|
glCheck(GLEXT_glUniformMatrix4fv(binder.location, static_cast<GLsizei>(length), GL_FALSE, !contiguous.empty() ? &contiguous[0] : NULL));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user