diff options
author | Ruben Brunk <rubenbrunk@google.com> | 2015-01-09 13:48:31 -0800 |
---|---|---|
committer | Ruben Brunk <rubenbrunk@google.com> | 2015-01-09 13:48:31 -0800 |
commit | a3fdec8dac09b178d642c07a538c42faf84c2aaa (patch) | |
tree | c132aae353c69195a29fd1dc3145ff1b3ace1703 /core/jni | |
parent | 1c6014e77dfad1a7af229d642df7b7300beee721 (diff) | |
download | frameworks_base-a3fdec8dac09b178d642c07a538c42faf84c2aaa.zip frameworks_base-a3fdec8dac09b178d642c07a538c42faf84c2aaa.tar.gz frameworks_base-a3fdec8dac09b178d642c07a538c42faf84c2aaa.tar.bz2 |
Camera2: Fix early EOF in DngCreator#writeByteBuffer.
Bug: 18962278
Change-Id: I8641a03d866930c86bdd2db0a29ccd5560712c90
Diffstat (limited to 'core/jni')
-rw-r--r-- | core/jni/android_hardware_camera2_DngCreator.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/core/jni/android_hardware_camera2_DngCreator.cpp b/core/jni/android_hardware_camera2_DngCreator.cpp index 533313a..7361858 100644 --- a/core/jni/android_hardware_camera2_DngCreator.cpp +++ b/core/jni/android_hardware_camera2_DngCreator.cpp @@ -35,6 +35,7 @@ #include <cutils/properties.h> #include <string.h> +#include <inttypes.h> #include "android_runtime/AndroidRuntime.h" #include "android_runtime/android_hardware_camera2_CameraMetadata.h" @@ -360,15 +361,18 @@ ssize_t JniInputByteBuffer::read(uint8_t* buf, size_t offset, size_t count) { realCount = count; } - mEnv->CallObjectMethod(mInBuf, gInputByteBufferClassInfo.mGetMethod, mByteArray, 0, + jobject chainingBuf = mEnv->CallObjectMethod(mInBuf, gInputByteBufferClassInfo.mGetMethod, mByteArray, 0, realCount); + mEnv->DeleteLocalRef(chainingBuf); if (mEnv->ExceptionCheck()) { + ALOGE("%s: Exception while reading from input into byte buffer.", __FUNCTION__); return BAD_VALUE; } mEnv->GetByteArrayRegion(mByteArray, 0, realCount, reinterpret_cast<jbyte*>(buf + offset)); if (mEnv->ExceptionCheck()) { + ALOGE("%s: Exception while reading from byte buffer.", __FUNCTION__); return BAD_VALUE; } return realCount; @@ -469,15 +473,17 @@ status_t InputStripSource::writeToStream(Output& stream, uint32_t count) { for (uint32_t i = 0; i < mHeight; ++i) { size_t rowFillAmt = 0; - size_t rowSize = mPixStride; + size_t rowSize = mRowStride; while (rowFillAmt < mRowStride) { ssize_t bytesRead = mInput->read(rowBytes, rowFillAmt, rowSize); if (bytesRead <= 0) { if (bytesRead == NOT_ENOUGH_DATA || bytesRead == 0) { + ALOGE("%s: Early EOF on row %" PRIu32 ", received bytesRead %zd", + __FUNCTION__, i, bytesRead); jniThrowExceptionFmt(mEnv, "java/io/IOException", - "Early EOF encountered, not enough pixel data for image of size %u", - fullSize); + "Early EOF encountered, not enough pixel data for image of size %" + PRIu32, fullSize); bytesRead = NOT_ENOUGH_DATA; } else { if (!mEnv->ExceptionCheck()) { |