ImGui: Use safe strcat/scanf on MSVC
This commit is contained in:
parent
8582e2770d
commit
d7962fdac7
|
@ -63,10 +63,6 @@
|
||||||
// ES 3.0 300 "#version 300 es" = WebGL 2.0
|
// ES 3.0 300 "#version 300 es" = WebGL 2.0
|
||||||
//----------------------------------------
|
//----------------------------------------
|
||||||
|
|
||||||
#if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS)
|
|
||||||
#define _CRT_SECURE_NO_WARNINGS
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "imgui.h"
|
#include "imgui.h"
|
||||||
#include "imgui_impl_opengl3.h"
|
#include "imgui_impl_opengl3.h"
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -126,8 +122,13 @@ bool ImGui_ImplOpenGL3_Init(const char* glsl_version)
|
||||||
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
io.BackendFlags |= ImGuiBackendFlags_RendererHasVtxOffset; // We can honor the ImDrawCmd::VtxOffset field, allowing for large meshes.
|
||||||
|
|
||||||
IM_ASSERT((int)strlen(glsl_version) + 2 < IM_ARRAYSIZE(g_GlslVersionString));
|
IM_ASSERT((int)strlen(glsl_version) + 2 < IM_ARRAYSIZE(g_GlslVersionString));
|
||||||
|
#ifndef _MSC_VER
|
||||||
strcpy(g_GlslVersionString, glsl_version);
|
strcpy(g_GlslVersionString, glsl_version);
|
||||||
strcat(g_GlslVersionString, "\n");
|
strcat(g_GlslVersionString, "\n");
|
||||||
|
#else
|
||||||
|
strncpy_s(g_GlslVersionString, sizeof(g_GlslVersionString), glsl_version, _TRUNCATE);
|
||||||
|
strncat_s(g_GlslVersionString, sizeof(g_GlslVersionString), "\n", _TRUNCATE);
|
||||||
|
#endif
|
||||||
return ImGui_ImplOpenGL3_CreateDeviceObjects();
|
return ImGui_ImplOpenGL3_CreateDeviceObjects();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -363,7 +364,11 @@ bool ImGui_ImplOpenGL3_CreateDeviceObjects()
|
||||||
|
|
||||||
// Parse GLSL version string
|
// Parse GLSL version string
|
||||||
int glsl_version = 130;
|
int glsl_version = 130;
|
||||||
|
#ifndef _MSC_VER
|
||||||
sscanf(g_GlslVersionString, "#version %d", &glsl_version);
|
sscanf(g_GlslVersionString, "#version %d", &glsl_version);
|
||||||
|
#else
|
||||||
|
sscanf_s(g_GlslVersionString, "#version %d", &glsl_version);
|
||||||
|
#endif
|
||||||
|
|
||||||
const GLchar* vertex_shader_glsl_120 =
|
const GLchar* vertex_shader_glsl_120 =
|
||||||
"uniform mat4 ProjMtx;\n"
|
"uniform mat4 ProjMtx;\n"
|
||||||
|
|
Loading…
Reference in New Issue