Skip to content
Snippets Groups Projects
Commit 00089f9c authored by stepan's avatar stepan
Browse files

NFI Context lookupNativeFunction: avoid potential NPEs

parent a923e593
No related branches found
No related tags found
No related merge requests found
......@@ -123,9 +123,17 @@ final class TruffleNFI_Context extends RFFIContext {
if (function.getLibrary() == NativeFunction.baseLibrary()) {
dllInfo = TruffleNFI_Context.getInstance().defaultLibrary;
} else if (function.getLibrary() == NativeFunction.anyLibrary()) {
dllInfo = ((NFIHandle) DLL.findLibraryContainingSymbol(function.getCallName()).handle).libHandle;
DLLInfo lib = DLL.findLibraryContainingSymbol(function.getCallName());
if (lib == null) {
throw RInternalError.shouldNotReachHere("Could not find library containing symbol " + function.getCallName());
}
dllInfo = ((NFIHandle) lib.handle).libHandle;
} else {
dllInfo = ((NFIHandle) DLL.findLibrary(function.getLibrary()).handle).libHandle;
DLLInfo lib = DLL.findLibrary(function.getLibrary());
if (lib == null) {
throw RInternalError.shouldNotReachHere("Could not find library " + function.getLibrary());
}
dllInfo = ((NFIHandle) lib.handle).libHandle;
}
try {
TruffleObject symbol = ((TruffleObject) ForeignAccess.sendRead(Message.READ.createNode(), dllInfo, function.getCallName()));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment