From 4a5bff2d421989c1df5963187e0b94bd24b0bb61 Mon Sep 17 00:00:00 2001 From: Ran Date: Tue, 8 Oct 2019 00:57:41 -0700 Subject: [PATCH] Initialize dynamicMethods before use (#9618) Motivation: There is a goto statement above the current position of initialize dynamicMethods, and dynamicMethods is used after the goto which might cause undefined behavior. Modifications: Initialize dynamicMehtods at the top. Result: No more undefined behavior. --- transport-native-epoll/src/main/c/netty_epoll_native.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/transport-native-epoll/src/main/c/netty_epoll_native.c b/transport-native-epoll/src/main/c/netty_epoll_native.c index 4d74c8faed..cac6472a16 100644 --- a/transport-native-epoll/src/main/c/netty_epoll_native.c +++ b/transport-native-epoll/src/main/c/netty_epoll_native.c @@ -547,6 +547,7 @@ static jint netty_epoll_native_JNI_OnLoad(JNIEnv* env, const char* packagePrefix int linuxsocketOnLoadCalled = 0; char* nettyClassName = NULL; jclass nativeDatagramPacketCls = NULL; + JNINativeMethod* dynamicMethods = NULL; // We must register the statically referenced methods first! if (netty_unix_util_register_natives(env, @@ -557,7 +558,7 @@ static jint netty_epoll_native_JNI_OnLoad(JNIEnv* env, const char* packagePrefix goto done; } // Register the methods which are not referenced by static member variables - JNINativeMethod* dynamicMethods = createDynamicMethodsTable(packagePrefix); + dynamicMethods = createDynamicMethodsTable(packagePrefix); if (dynamicMethods == NULL) { goto done; }