Hi, Simple patch to fix a use of memset to reset an array of floats and glm::vec3f's to 0.
This is unsafe, not least as float types have implementation-defined value representations [1]. Memory-0 = float-0 is true for IEEE-754, and glm::vec3f happens to not have any book-keeping data that could be smashed by this (if m_materials contained a std::string or std::vector, this would be very bad karma), so it does happen to work. Cheers, John [1]: http://www.open-std.org/jtc1/sc22/open/n2356/basic.html#basic.fundamental
From b02038bf470d0c8cb8fd552969f36d51bb8afe6b Mon Sep 17 00:00:00 2001 From: John Beard <[email protected]> Date: Fri, 9 Nov 2018 11:58:38 +0000 Subject: [PATCH] Don't use memset to initialise aggregate of floats. In C3D_RENDER_OGL_LEGACY::setupMaterial(), the struct m_materials (which is made up of floats and glm::vec3f's) is initialised with a memset to 0. This is unsafe, as floating point value representations in C++ are implementation- defined (so 0 in memory is not 0-valued for sure). Use empty-brace aggregate-initialisation, which does the right thing. --- .../3d_render_ogl_legacy/c3d_render_ogl_legacy.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.cpp b/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.cpp index 6498d0f9b..dc9dd0082 100644 --- a/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.cpp +++ b/3d-viewer/3d_rendering/3d_render_ogl_legacy/c3d_render_ogl_legacy.cpp @@ -175,8 +175,7 @@ void C3D_RENDER_OGL_LEGACY::render_3D_arrows() void C3D_RENDER_OGL_LEGACY::setupMaterials() { - - memset( &m_materials, 0, sizeof( m_materials ) ); + m_materials = {}; if( m_settings.GetFlag( FL_USE_REALISTIC_MODE ) ) { -- 2.19.1
_______________________________________________ Mailing list: https://launchpad.net/~kicad-developers Post to : [email protected] Unsubscribe : https://launchpad.net/~kicad-developers More help : https://help.launchpad.net/ListHelp

