libnativebridge: fix a potential null deref
Caught by the static analyzer:
> art/libnativebridge/native_bridge.cc:239:40: warning: Access to field
'version' results in a dereference of a null pointer (loaded from
variable 'callbacks') [clang-analyzer-core.NullDereference]
Bug: None
Test: TreeHugger
Change-Id: Ia0eb0daac6ee3b07b9ffd615cec9f0a431de2900
diff --git a/libnativebridge/native_bridge.cc b/libnativebridge/native_bridge.cc
index 7600780..46a05a2 100644
--- a/libnativebridge/native_bridge.cc
+++ b/libnativebridge/native_bridge.cc
@@ -233,10 +233,10 @@
// Store the handle for later.
native_bridge_handle = handle;
} else {
- callbacks = nullptr;
- dlclose(handle);
ALOGW("Unsupported native bridge API in %s (is version %d not compatible with %d)",
nb_library_filename, callbacks->version, NAMESPACE_VERSION);
+ callbacks = nullptr;
+ dlclose(handle);
}
} else {
dlclose(handle);