From 6eca44464e28309a067ce4e694970ab2e6682993 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 19 Jan 2019 23:10:46 +0100 Subject: [PATCH] load_dso: prevent load_dso_error() from returning old error This happens if load_dso fails due to being unable to find the file, but not setting the dlerror flag and therefore causing a misleading error message to be shown. --- dtool/src/dtoolutil/load_dso.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dtool/src/dtoolutil/load_dso.cxx b/dtool/src/dtoolutil/load_dso.cxx index 79d821b5fa..0c7ae24ebe 100644 --- a/dtool/src/dtoolutil/load_dso.cxx +++ b/dtool/src/dtoolutil/load_dso.cxx @@ -132,6 +132,9 @@ void * load_dso(const DSearchPath &path, const Filename &filename) { Filename abspath = resolve_dso(path, filename); if (!abspath.is_regular_file()) { + // Make sure the error flag is cleared, to prevent a subsequent call to + // load_dso_error() from returning a previously stored error. + dlerror(); return nullptr; } string os_specific = abspath.to_os_specific();