Skip to content

Commit

Permalink
Initialize regs[] to 0 in check_for_x86_simd (#1509)
Browse files Browse the repository at this point in the history
gcc warns of a potentially uninitialized memory reference, in the case
where ``__get_cpuid()`` fails to assign values to all its parameters.

Signed-off-by: Cary Phillips <[email protected]>
  • Loading branch information
cary-ilm authored Aug 9, 2023
1 parent 5bd66ff commit d688d05
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib/OpenEXRCore/internal_cpuid.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ check_for_x86_simd (int* f16c, int* avx, int* sse2)
#elif OPENEXR_ENABLE_X86_SIMD_CHECK

# if defined(_MSC_VER) && defined(_WIN32)
int regs[4], osxsave;
int regs[4]={0}, osxsave;

__cpuid (regs, 0);
if (regs[0] >= 1) { __cpuidex (regs, 1, 0); }
else
regs[2] = 0;
# else
unsigned int regs[4], osxsave;
unsigned int regs[4]={0}, osxsave;
__get_cpuid (0, &regs[0], &regs[1], &regs[2], &regs[3]);
if (regs[0] >= 1)
{
Expand Down

0 comments on commit d688d05

Please sign in to comment.