File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
media/libstagefright/codecs Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 33
33
34
34
#include " SoftMPEG4Encoder.h"
35
35
36
+ #ifndef INT32_MAX
37
+ #define INT32_MAX 2147483647
38
+ #endif
39
+
36
40
namespace android {
37
41
38
42
template <class T >
@@ -149,7 +153,12 @@ OMX_ERRORTYPE SoftMPEG4Encoder::initEncParams() {
149
153
150
154
if (mVideoColorFormat == OMX_COLOR_FormatYUV420SemiPlanar) {
151
155
// Color conversion is needed.
152
- CHECK (mInputFrameData == NULL );
156
+ free (mInputFrameData );
157
+ mInputFrameData = NULL ;
158
+ if (((uint64_t )mVideoWidth * mVideoHeight ) > ((uint64_t )INT32_MAX / 3 )) {
159
+ ALOGE (" b/25812794, Buffer size is too big." );
160
+ return OMX_ErrorBadParameter;
161
+ }
153
162
mInputFrameData =
154
163
(uint8_t *) malloc ((mVideoWidth * mVideoHeight * 3 ) >> 1 );
155
164
CHECK (mInputFrameData != NULL );
Original file line number Diff line number Diff line change 25
25
#include < media/stagefright/foundation/ADebug.h>
26
26
#include < media/stagefright/MediaDefs.h>
27
27
28
+ #ifndef INT32_MAX
29
+ #define INT32_MAX 2147483647
30
+ #endif
31
+
28
32
namespace android {
29
33
30
34
@@ -300,6 +304,10 @@ status_t SoftVPXEncoder::initEncoder() {
300
304
301
305
if (mColorFormat == OMX_COLOR_FormatYUV420SemiPlanar || mInputDataIsMeta ) {
302
306
if (mConversionBuffer == NULL ) {
307
+ if (((uint64_t )mWidth * mHeight ) > ((uint64_t )INT32_MAX / 3 )) {
308
+ ALOGE (" b/25812794, Buffer size is too big." );
309
+ return UNKNOWN_ERROR;
310
+ }
303
311
mConversionBuffer = (uint8_t *)malloc (mWidth * mHeight * 3 / 2 );
304
312
if (mConversionBuffer == NULL ) {
305
313
ALOGE (" Allocating conversion buffer failed." );
You can’t perform that action at this time.
0 commit comments