comparison 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
comparison
equal deleted inserted replaced
6:63447e93b71e 7:82613a4479e8
47 * of the com.oracle.dio.impl.EventQueue class for details. 47 * of the com.oracle.dio.impl.EventQueue class for details.
48 */ 48 */
49 void event_queue_put_native_event 49 void event_queue_put_native_event
50 (JavaVM* cachedJVM, const char* device_type, const char *payload, int payload_size) { 50 (JavaVM* cachedJVM, const char* device_type, const char *payload, int payload_size) {
51 JNIEnv* env; 51 JNIEnv* env;
52 cachedJVM->AttachCurrentThread((void**)&env, NULL); 52 if (NULL == eventBuffer) {
53 JAVACALL_REPORT_ERROR(JC_DIO, "Event queue is not initialized properly");
54 return;
55 }
56 cachedJVM->AttachCurrentThread((void **)&env, NULL);
53 57
54 jclass bufferClass = env->GetObjectClass(eventBuffer); 58 jclass bufferClass = env->GetObjectClass(eventBuffer);
55 jmethodID notifyID = bufferClass ? env->GetMethodID(bufferClass, "notify", "()V") : 59 jmethodID notifyID = bufferClass ? env->GetMethodID(bufferClass, "notify", "()V") :
56 NULL; 60 NULL;
57 jmethodID limitID = notifyID ? env->GetMethodID(bufferClass, "limit", "()I") : 61 jmethodID limitID = notifyID ? env->GetMethodID(bufferClass, "limit", "()I") :