diff options
author | Ruben Brunk <rubenbrunk@google.com> | 2014-08-29 17:25:13 -0700 |
---|---|---|
committer | Ruben Brunk <rubenbrunk@google.com> | 2014-08-29 17:25:13 -0700 |
commit | 65e01f763571b779fbc759e6f96d0a195b94c6da (patch) | |
tree | e8008be890121edd3f01af0d99c1d081c4629390 /services | |
parent | 355286ee1e5057c66158fcea785bf1881e069101 (diff) | |
download | frameworks_av-65e01f763571b779fbc759e6f96d0a195b94c6da.zip frameworks_av-65e01f763571b779fbc759e6f96d0a195b94c6da.tar.gz frameworks_av-65e01f763571b779fbc759e6f96d0a195b94c6da.tar.bz2 |
camera1: Ensure MemoryHeap buffers are mmapped before copying.
Bug: 16986293
Change-Id: Icb68254d7ed1812fa9e60342749a2746d6fcfb17
Diffstat (limited to 'services')
-rw-r--r-- | services/camera/libcameraservice/api1/CameraClient.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/services/camera/libcameraservice/api1/CameraClient.cpp b/services/camera/libcameraservice/api1/CameraClient.cpp index abe1235..33bdaa3 100644 --- a/services/camera/libcameraservice/api1/CameraClient.cpp +++ b/services/camera/libcameraservice/api1/CameraClient.cpp @@ -938,7 +938,20 @@ void CameraClient::copyFrameAndPostCopiedFrame( } previewBuffer = mPreviewBuffer; - memcpy(previewBuffer->base(), (uint8_t *)heap->base() + offset, size); + void* previewBufferBase = previewBuffer->base(); + void* heapBase = heap->base(); + + if (heapBase == MAP_FAILED) { + ALOGE("%s: Failed to mmap heap for preview frame.", __FUNCTION__); + mLock.unlock(); + return; + } else if (previewBufferBase == MAP_FAILED) { + ALOGE("%s: Failed to mmap preview buffer for preview frame.", __FUNCTION__); + mLock.unlock(); + return; + } + + memcpy(previewBufferBase, (uint8_t *) heapBase + offset, size); sp<MemoryBase> frame = new MemoryBase(previewBuffer, 0, size); if (frame == 0) { |