Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 429a3b5f authored by James Dong's avatar James Dong
Browse files

Fix a JNI layer crash due to null camera object passed to get_native_camera()

The fix will check on the camera object and if it is a null object, we
throw a NullPointerException; application layer should also avoid passing a null
java object to MediaRecorder.setCamera().
parent 0efb0868
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -150,6 +150,11 @@ static sp<MediaRecorder> setMediaRecorder(JNIEnv* env, jobject thiz, const sp<Me

static void android_media_MediaRecorder_setCamera(JNIEnv* env, jobject thiz, jobject camera)
{
    // we should not pass a null camera to get_native_camera() call.
    if (camera == NULL) {
        jniThrowException(env, "java/lang/NullPointerException", "camera object is a NULL pointer");
        return;
    }
    sp<Camera> c = get_native_camera(env, camera, NULL);
    sp<MediaRecorder> mr = getMediaRecorder(env, thiz);
    process_media_recorder_call(env, mr->setCamera(c->remote()),