diff src/se/native/com/oracle/dio/dio_event_queue.cpp @ 251:4045c31c14f9

8136841: Segmentation fault if GPIO input pin is litened Summary: Reorder listener assigment and start notification calls, javanotify is guarded against uninitialized variables. Reviewed-by: alkonsta
author snazarki
date Tue, 22 Sep 2015 18:40:20 +0300
parents 2c0af8cb3202
children 4299ff23b184
line wrap: on
line diff
--- a/src/se/native/com/oracle/dio/dio_event_queue.cpp	Tue Sep 15 12:54:17 2015 +0300
+++ b/src/se/native/com/oracle/dio/dio_event_queue.cpp	Tue Sep 22 18:40:20 2015 +0300
@@ -49,7 +49,11 @@
 void event_queue_put_native_event
   (JavaVM* cachedJVM, const char* device_type, const char *payload, int payload_size) {
     JNIEnv* env;
-    cachedJVM->AttachCurrentThread((void**)&env, NULL);
+    if (NULL == eventBuffer) {
+        JAVACALL_REPORT_ERROR(JC_DIO, "Event queue is not initialized properly");
+        return;
+    }
+    cachedJVM->AttachCurrentThread((void **)&env, NULL);
 
     jclass bufferClass = env->GetObjectClass(eventBuffer);
     jmethodID notifyID = bufferClass ? env->GetMethodID(bufferClass, "notify", "()V") :