Add null checks for *Buffer params
This change prevents crashes in native layers and throws an exception
instead.
Bug: 25695785
Test: CtsGraphicsTestCases
Change-Id: I0b4115e001099f579f53e47fa5cb9c851c6dabdb
diff --git a/core/jni/android_opengl_GLES10Ext.cpp b/core/jni/android_opengl_GLES10Ext.cpp
index 4dc4233..533bda4 100644
--- a/core/jni/android_opengl_GLES10Ext.cpp
+++ b/core/jni/android_opengl_GLES10Ext.cpp
@@ -540,6 +540,12 @@
jint _exponentRemaining;
GLint *exponent = (GLint *) 0;
+ if (!mantissa_buf) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "mantissa == null";
+ goto exit;
+ }
mantissa = (GLfixed *)getPointer(_env, mantissa_buf, (jarray*)&_mantissaArray, &_mantissaRemaining, &_mantissaBufferOffset);
if (_mantissaRemaining < 16) {
_exception = 1;
@@ -547,6 +553,12 @@
_exceptionMessage = "remaining() < 16 < needed";
goto exit;
}
+ if (!exponent_buf) {
+ _exception = 1;
+ _exceptionType = "java/lang/IllegalArgumentException";
+ _exceptionMessage = "exponent == null";
+ goto exit;
+ }
exponent = (GLint *)getPointer(_env, exponent_buf, (jarray*)&_exponentArray, &_exponentRemaining, &_exponentBufferOffset);
if (_exponentRemaining < 16) {
_exception = 1;