Bug 1167531 - Uninitialised value uses relating to GonkDisplayJB::GonkDisplayJB. r=mwu.
authorJulian Seward <jseward@acm.org>
Wed, 27 May 2015 09:41:53 +0200
changeset 268027 ec2a1ba41a7a353443218fc7805ba3be8ba02a28
parent 268026 120ff7bb304abf390596926bf4ced675c2f77b50
child 268028 82a58c5b693908019bd33c6d45244c542eaee81a
push id2294
push userbsmedberg@mozilla.com
push dateWed, 27 May 2015 15:05:10 +0000
reviewersmwu
bugs1167531
milestone41.0a1
Bug 1167531 - Uninitialised value uses relating to GonkDisplayJB::GonkDisplayJB. r=mwu.
widget/gonk/libdisplay/GonkDisplayJB.cpp
--- a/widget/gonk/libdisplay/GonkDisplayJB.cpp
+++ b/widget/gonk/libdisplay/GonkDisplayJB.cpp
@@ -40,16 +40,18 @@ static GonkDisplayJB* sGonkDisplay = nul
 
 GonkDisplayJB::GonkDisplayJB()
     : mModule(nullptr)
     , mFBModule(nullptr)
     , mHwc(nullptr)
     , mFBDevice(nullptr)
     , mPowerModule(nullptr)
     , mList(nullptr)
+    , mWidth(0)
+    , mHeight(0)
     , mEnabledCallback(nullptr)
 {
     int err = hw_get_module(GRALLOC_HARDWARE_MODULE_ID, &mFBModule);
     ALOGW_IF(err, "%s module not found", GRALLOC_HARDWARE_MODULE_ID);
     if (!err) {
         err = framebuffer_open(mFBModule, &mFBDevice);
         ALOGW_IF(err, "could not open framebuffer");
     }
@@ -103,17 +105,17 @@ GonkDisplayJB::GonkDisplayJB()
     if (!err)
         mPowerModule->init(mPowerModule);
     ALOGW_IF(err, "Couldn't load %s module (%s)", POWER_HARDWARE_MODULE_ID, strerror(-err));
 
     mAlloc = new GraphicBufferAlloc();
 
     CreateSurface(mSTClient, mDispSurface);
 
-    mList = (hwc_display_contents_1_t *)malloc(sizeof(*mList) + (sizeof(hwc_layer_1_t)*2));
+    mList = (hwc_display_contents_1_t *)calloc(1, sizeof(*mList) + (sizeof(hwc_layer_1_t)*2));
 
     uint32_t usage = GRALLOC_USAGE_HW_FB | GRALLOC_USAGE_HW_RENDER | GRALLOC_USAGE_HW_COMPOSER;
     if (mFBDevice) {
         // If device uses fb, they can not use single buffer for boot animation
         mSTClient->perform(mSTClient.get(), NATIVE_WINDOW_SET_BUFFER_COUNT, 2);
         mSTClient->perform(mSTClient.get(), NATIVE_WINDOW_SET_USAGE, usage);
     } else if (mHwc) {
 #if ANDROID_VERSION >= 21