[automerger] Check for overflow of crypto size am: d1fd027612

Change-Id: I065fd02eeebfacd1e525bf52d0b17787ab8db9b2
gugelfrei
Android Build Merger (Role) 6 years ago
commit fe8dc06116

@ -447,7 +447,13 @@ AMediaCodecCryptoInfo *AMediaCodecCryptoInfo_new(
size_t *encryptedbytes) {
// size needed to store all the crypto data
size_t cryptosize = sizeof(AMediaCodecCryptoInfo) + sizeof(size_t) * numsubsamples * 2;
size_t cryptosize;
// = sizeof(AMediaCodecCryptoInfo) + sizeof(size_t) * numsubsamples * 2;
if (__builtin_mul_overflow(sizeof(size_t) * 2, numsubsamples, &cryptosize) ||
__builtin_add_overflow(cryptosize, sizeof(AMediaCodecCryptoInfo), &cryptosize)) {
ALOGE("crypto size overflow");
return NULL;
}
AMediaCodecCryptoInfo *ret = (AMediaCodecCryptoInfo*) malloc(cryptosize);
if (!ret) {
ALOGE("couldn't allocate %zu bytes", cryptosize);

Loading…
Cancel
Save