Codec2BufferUtils.cpp: Fix integer-overflows
Fix integer overflows in IsNV12 and IsNV21
Bug: 185277572
Test: atest VtsHalMediaC2V1_0TargetVideoEncTest
Change-Id: I940456cf7f26696f42d885531b0b73d064de921e
diff --git a/media/codec2/sfplugin/utils/Codec2BufferUtils.cpp b/media/codec2/sfplugin/utils/Codec2BufferUtils.cpp
index a78d811..0966988 100644
--- a/media/codec2/sfplugin/utils/Codec2BufferUtils.cpp
+++ b/media/codec2/sfplugin/utils/Codec2BufferUtils.cpp
@@ -346,7 +346,7 @@
}
return (img->mPlane[1].mColInc == 2
&& img->mPlane[2].mColInc == 2
- && (img->mPlane[2].mOffset - img->mPlane[1].mOffset == 1));
+ && (img->mPlane[2].mOffset == img->mPlane[1].mOffset + 1));
}
bool IsNV21(const MediaImage2 *img) {
@@ -355,7 +355,7 @@
}
return (img->mPlane[1].mColInc == 2
&& img->mPlane[2].mColInc == 2
- && (img->mPlane[1].mOffset - img->mPlane[2].mOffset == 1));
+ && (img->mPlane[1].mOffset == img->mPlane[2].mOffset + 1));
}
bool IsI420(const MediaImage2 *img) {