Skip to content

Commit

Permalink
SF: Fix Klockwork errors.
Browse files Browse the repository at this point in the history
Resolve klockwork errors in frameworks/native
to avoid buffer overflow and memory leaks.

Change-Id: I7af17047538e621c872377090cea5b96f0924883
  • Loading branch information
Praveena Pachipulusu authored and hyperb1iss committed Jul 7, 2014
1 parent a31051e commit f17754a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
4 changes: 3 additions & 1 deletion libs/gui/Surface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
5 changes: 4 additions & 1 deletion libs/gui/SurfaceControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion libs/ui/Region.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions services/surfaceflinger/DisplayHardware/HWComposer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down

0 comments on commit f17754a

Please sign in to comment.