Fixed possible crash.
STK could crash when invalid graphics restriction name was set in graphics_restrictions.xml file. It's because of wrong while (m_names_of_restrictions[i] != NULL) condition.
This commit is contained in:
parent
23acade026
commit
fb0a54278a
@ -26,6 +26,7 @@
|
||||
#include "utils/types.hpp"
|
||||
|
||||
#include <algorithm>
|
||||
#include <array>
|
||||
|
||||
namespace GraphicsRestrictions
|
||||
{
|
||||
@ -39,7 +40,7 @@ namespace GraphicsRestrictions
|
||||
/** The list of names used in the XML file for the graphics
|
||||
* restriction types. They must be in the same order as the types. */
|
||||
|
||||
const char *m_names_of_restrictions[] = {
|
||||
std::array<std::string, 27> m_names_of_restrictions = {
|
||||
"UniformBufferObject",
|
||||
"GeometryShader",
|
||||
"DrawIndirect",
|
||||
@ -58,10 +59,8 @@ namespace GraphicsRestrictions
|
||||
"AMDVertexShaderLayer",
|
||||
"ExplicitAttribLocation",
|
||||
"TextureFilterAnisotropic",
|
||||
#if defined(USE_GLES2)
|
||||
"TextureFormatBGRA8888",
|
||||
"ColorBufferFloat",
|
||||
#endif
|
||||
"DriverRecentEnough",
|
||||
"HighDefinitionTextures",
|
||||
"AdvancedPipeline",
|
||||
@ -77,12 +76,10 @@ namespace GraphicsRestrictions
|
||||
* GR_COUNT if the name is not found. */
|
||||
GraphicsRestrictionsType getTypeForName(const std::string &name)
|
||||
{
|
||||
unsigned int i = 0;
|
||||
while (m_names_of_restrictions[i] != NULL)
|
||||
for (unsigned int i = 0; i < m_names_of_restrictions.size(); i++)
|
||||
{
|
||||
if (name == m_names_of_restrictions[i])
|
||||
return (GraphicsRestrictionsType)i;
|
||||
i++;
|
||||
}
|
||||
return GR_COUNT;
|
||||
} // getTypeForName
|
||||
|
@ -52,10 +52,8 @@ namespace GraphicsRestrictions
|
||||
GR_AMD_VERTEX_SHADER_LAYER,
|
||||
GR_EXPLICIT_ATTRIB_LOCATION,
|
||||
GR_TEXTURE_FILTER_ANISOTROPIC,
|
||||
#if defined(USE_GLES2)
|
||||
GR_TEXTURE_FORMAT_BGRA8888,
|
||||
GR_COLOR_BUFFER_FLOAT,
|
||||
#endif
|
||||
GR_DRIVER_RECENT_ENOUGH,
|
||||
GR_HIGHDEFINITION_TEXTURES,
|
||||
GR_ADVANCED_PIPELINE,
|
||||
|
Loading…
Reference in New Issue
Block a user