command_buffer: Avoid uninitialized read in ShaderTranslatorCache
commitd67d827a4f58eb06fecc3aa396683495bec7c0dd
authorkkinnunen <kkinnunen@nvidia.com>
Wed, 12 Nov 2014 11:09:47 +0000 (12 03:09 -0800)
committerCommit bot <commit-bot@chromium.org>
Wed, 12 Nov 2014 11:10:08 +0000 (12 11:10 +0000)
tree23208851ab4b5319f3280bdb9ca31d5808491355
parentd783e8016a6e5f43ec94e2e7d4cf79c705e1638f
command_buffer: Avoid uninitialized read in ShaderTranslatorCache

The key in ShaderTranslatorCache std::map is copied with memcpy and
compared with memcmp. However, the key is a class that does not
guarantee not having any padding.

Padding in ShBuiltInResources causes the comparison be invalid. Valgrind
reports uninitialized reads for this.

Fix by preserving usage of memcmp. Initialize the object
with memset. This should write any possible padding data to a
well-defined state.

Depends on an ANGLE fix where ShBuiltInResources is similarly
initialized with memset. The resource data is copied to the key
implicitly, and this may or may not copy the padding.

Review URL: https://codereview.chromium.org/654253002

Cr-Commit-Position: refs/heads/master@{#303817}
gpu/BUILD.gn
gpu/command_buffer/service/shader_translator_cache.h
gpu/command_buffer/service/shader_translator_cache_unittest.cc [new file with mode: 0644]
gpu/gpu.gyp