Merge "Catch nullptr possibilities in MediaExtractor jni code" into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
d63a1d1644
@@ -196,6 +196,15 @@ status_t JMediaExtractor::readSampleData(
|
||||
dstSize = (size_t) env->GetDirectBufferCapacity(byteBuf);
|
||||
}
|
||||
|
||||
// unlikely, but GetByteArrayElements() can fail
|
||||
if (dst == nullptr) {
|
||||
ALOGE("no buffer into which to read the data");
|
||||
if (byteArray != NULL) {
|
||||
env->ReleaseByteArrayElements(byteArray, (jbyte *)dst, 0);
|
||||
}
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
if (dstSize < offset) {
|
||||
if (byteArray != NULL) {
|
||||
env->ReleaseByteArrayElements(byteArray, (jbyte *)dst, 0);
|
||||
@@ -204,8 +213,10 @@ status_t JMediaExtractor::readSampleData(
|
||||
return -ERANGE;
|
||||
}
|
||||
|
||||
// passes in the backing memory to use, so it doesn't fail
|
||||
sp<ABuffer> buffer = new ABuffer((char *)dst + offset, dstSize - offset);
|
||||
|
||||
buffer->setRange(0, 0); // mark it empty
|
||||
status_t err = mImpl->readSampleData(buffer);
|
||||
|
||||
if (byteArray != NULL) {
|
||||
|
||||
Reference in New Issue
Block a user