Add missing bounds checks

Bug: 231986464
Test: Manually, using POC from bug and using Photos RTSP playback.
Change-Id: Ie3494d592e7b36629317ba51717b528dab13e0fb
(cherry picked from commit ed1b480e202fb58caa9e7ce8b00ccaa6a3b125c0)
Merged-In: Ie3494d592e7b36629317ba51717b528dab13e0fb
(cherry picked from commit 2ebfe99b3a31aad82f8a186b136037509714d874)
Merged-In: Ie3494d592e7b36629317ba51717b528dab13e0fb
1 file changed