android: camera_device: Fix crash of accessing a missing map element

std::map::at() searches std::map by the given key. The commit
e1f9fdb8a5 ("android: camera_device: Remove shadowing FrameBuffer
usage") uses it with 0 to intend to accessing the first element of the
map, but actually access the element whose key is nullptr. This causes
the crash because the map doesn't have the element with nullptr. This
fixes the issue by replacing the std::map::at() operation by
std::map::begin().

Signed-off-by: Hirokazu Honda <hiroh@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
[Kieran: Updated commit message]
Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
This commit is contained in:
Hirokazu Honda 2020-10-28 17:57:26 +09:00 committed by Kieran Bingham
parent bfd588d1d8
commit 3a777d8cc1

View file

@ -1525,7 +1525,7 @@ void CameraDevice::requestComplete(Request *request)
* It might be appropriate to return a 'correct' (as determined by
* pipeline handlers) timestamp in the Request itself.
*/
uint64_t timestamp = buffers.at(0)->metadata().timestamp;
uint64_t timestamp = buffers.begin()->second->metadata().timestamp;
resultMetadata = getResultMetadata(descriptor->frameNumber_, timestamp);
/* Handle any JPEG compression. */