From 5e25c50f187848cf6f5c1dbb5f3303214f604657 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Wed, 27 Aug 2014 14:22:38 +0800 Subject: [PATCH] tests: fix memory access with uninitialized values ch and num are uninitialized. --- tests/xgldevice.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/tests/xgldevice.cpp b/tests/xgldevice.cpp index 36f3ec75..e4097b75 100644 --- a/tests/xgldevice.cpp +++ b/tests/xgldevice.cpp @@ -50,9 +50,6 @@ void XglDevice::init_device() void XglDevice::init_formats() { - XGL_CHANNEL_FORMAT ch; - XGL_NUM_FORMAT num; - for (int chInt = XGL_CH_FMT_UNDEFINED; chInt < XGL_MAX_CH_FMT; chInt++) { for (int numInt = 0; numInt < XGL_MAX_NUM_FMT; numInt++) { XGL_FORMAT fmt = {}; @@ -64,13 +61,13 @@ void XglDevice::init_formats() err = xglGetFormatInfo(m_xgl_device_object, fmt, XGL_INFO_TYPE_FORMAT_PROPERTIES, - &size, &this->format_props[ch][num]); + &size, &this->format_props[chInt][numInt]); if (err) { - memset(&this->format_props[ch][num], 0, - sizeof(this->format_props[ch][num])); + memset(&this->format_props[chInt][numInt], 0, + sizeof(this->format_props[chInt][numInt])); } - else if (size != sizeof(this->format_props[ch][num])) { - ASSERT_EQ(size, sizeof(this->format_props[ch][num])) << "Incorrect data size"; + else if (size != sizeof(this->format_props[chInt][numInt])) { + ASSERT_EQ(size, sizeof(this->format_props[chInt][numInt])) << "Incorrect data size"; } } }