diff options
author | Praveena Pachipulusu <pveena@codeaurora.org> | 2014-06-19 12:10:56 +0530 |
---|---|---|
committer | Steve Kondik <shade@chemlab.org> | 2014-07-07 12:46:54 -0700 |
commit | f17754aa7a080661357510718a37010474ce80e2 (patch) | |
tree | 34d71dce9b6943914ad6c3f230287d4427262ae2 | |
parent | a31051e5550f83fbb86257a7ce93870374ee4c7f (diff) | |
download | android_frameworks_native-f17754aa7a080661357510718a37010474ce80e2.tar.gz android_frameworks_native-f17754aa7a080661357510718a37010474ce80e2.tar.bz2 android_frameworks_native-f17754aa7a080661357510718a37010474ce80e2.zip |
SF: Fix Klockwork errors.
Resolve klockwork errors in frameworks/native
to avoid buffer overflow and memory leaks.
Change-Id: I7af17047538e621c872377090cea5b96f0924883
-rw-r--r-- | libs/gui/Surface.cpp | 4 | ||||
-rw-r--r-- | libs/gui/SurfaceControl.cpp | 5 | ||||
-rw-r--r-- | libs/ui/Region.cpp | 4 | ||||
-rw-r--r-- | services/surfaceflinger/DisplayHardware/HWComposer.cpp | 2 |
4 files changed, 12 insertions, 3 deletions
diff --git a/libs/gui/Surface.cpp b/libs/gui/Surface.cpp index f72b78ea7..b699fedad 100644 --- a/libs/gui/Surface.cpp +++ b/libs/gui/Surface.cpp @@ -879,7 +879,9 @@ status_t Surface::lock( { // scope for the lock Mutex::Autolock lock(mMutex); - mSlots[backBufferSlot].dirtyRegion = newDirtyRegion; + if (backBufferSlot >= 0) { + mSlots[backBufferSlot].dirtyRegion = newDirtyRegion; + } } if (inOutDirtyBounds) { diff --git a/libs/gui/SurfaceControl.cpp b/libs/gui/SurfaceControl.cpp index 128dfbf7b..a4706385b 100644 --- a/libs/gui/SurfaceControl.cpp +++ b/libs/gui/SurfaceControl.cpp @@ -180,7 +180,10 @@ status_t SurfaceControl::writeSurfaceToParcel( if (control != NULL) { bp = control->mGraphicBufferProducer; } - return parcel->writeStrongBinder(bp->asBinder()); + if (bp != NULL) { + return parcel->writeStrongBinder(bp->asBinder()); + } + return NO_INIT; } sp<Surface> SurfaceControl::getSurface() const diff --git a/libs/ui/Region.cpp b/libs/ui/Region.cpp index e5abcf5c8..437f1cbe9 100644 --- a/libs/ui/Region.cpp +++ b/libs/ui/Region.cpp @@ -783,7 +783,9 @@ SharedBuffer const* Region::getSharedBuffer(size_t* count) const { size_t numRects = isRect() ? 1 : mStorage.size() - 1; count[0] = numRects; } - sb->acquire(); + if (sb != NULL) { + sb->acquire(); + } return sb; } diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp index 6b810c862..41d09b34d 100644 --- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp +++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp @@ -667,6 +667,8 @@ status_t HWComposer::createWorkList(int32_t id, size_t numLayers) { size_t size = sizeofHwcLayerList(mHwc, numLayers); free(disp.list); disp.list = (hwc_display_contents_1_t*)malloc(size); + if(disp.list == NULL) + return NO_MEMORY; disp.capacity = numLayers; } if (hwcHasApiVersion(mHwc, HWC_DEVICE_API_VERSION_1_1)) { |