From: Peter Rosin Date: Wed, 17 Mar 2010 08:01:57 +0000 (+0100) Subject: Preserve the last error when restoring the error mode. X-Git-Tag: v2.2.7b~14 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=f21029c498c2cf9f0481a203f91f538f0c290d58;p=thirdparty%2Flibtool.git Preserve the last error when restoring the error mode. * libltdl/loaders/loadlibrary.c (wm_open): Don't rely on SetThreadErrorMode (or SetErrorMode) to not clobber the last error. Report by Ralf Wildenhues. Signed-off-by: Peter Rosin --- diff --git a/ChangeLog b/ChangeLog index 3aed40009..5c36a742b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ 2010-03-17 Peter Rosin + Preserve the last error when restoring the error mode. + * libltdl/loaders/loadlibrary.c (wm_open): Don't rely on + SetThreadErrorMode (or SetErrorMode) to not clobber the last + error. + Report by Ralf Wildenhues. + Use Get/SetThreadErrorMode if they are available. * libltdl/loaders/loadlibrary.c (wrap_geterrormode): Replaced... (wrap_getthreaderrormode): ...by this function that checks diff --git a/libltdl/loaders/loadlibrary.c b/libltdl/loaders/loadlibrary.c index 620e7cf42..179c00980 100644 --- a/libltdl/loaders/loadlibrary.c +++ b/libltdl/loaders/loadlibrary.c @@ -192,12 +192,16 @@ vm_open (lt_user_data LT__UNUSED loader_data, const char *filename, { /* Silence dialog from LoadLibrary on some failures. */ DWORD errormode = getthreaderrormode (); + DWORD last_error; + setthreaderrormode (errormode | SEM_FAILCRITICALERRORS, NULL); module = LoadLibrary (wpath); /* Restore the error mode. */ + last_error = GetLastError (); setthreaderrormode (errormode, NULL); + SetLastError (last_error); } /* libltdl expects this function to fail if it is unable