From b8f643f3da35b359ceab4555a679d12422794d90 Mon Sep 17 00:00:00 2001 From: Mark Olesen Date: Fri, 25 Feb 2011 18:18:41 +0100 Subject: [PATCH] BUG: must use dlerror() to clear prev errors before using dlsym() --- src/OSspecific/POSIX/POSIX.C | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/OSspecific/POSIX/POSIX.C b/src/OSspecific/POSIX/POSIX.C index 4909d08244..43168336e6 100644 --- a/src/OSspecific/POSIX/POSIX.C +++ b/src/OSspecific/POSIX/POSIX.C @@ -1086,15 +1086,22 @@ bool Foam::dlClose(void* handle) void* Foam::dlSym(void* handle, const std::string& symbol) { + // clear any old errors - see manpage dlopen + (void) ::dlerror(); + + // get address of symbol void* fun = ::dlsym(handle, symbol.c_str()); - char *error; - if ((error = dlerror()) != NULL) + // find error (if any) + char *error = ::dlerror(); + + if (error) { WarningIn("dlSym(void*, const std::string&)") << "Cannot lookup symbol " << symbol << " : " << error << endl; } + return fun; }