summaryrefslogtreecommitdiffstats
path: root/win
diff options
context:
space:
mode:
authorjan.nijtmans <nijtmans@users.sourceforge.net>2017-11-03 12:57:15 (GMT)
committerjan.nijtmans <nijtmans@users.sourceforge.net>2017-11-03 12:57:15 (GMT)
commit5528e1c1a25f45988be72e2e16ff577f0dbb1abd (patch)
tree26ba5be3c875f141162b3833302bf0b1075f50f6 /win
parent274ab123a800239134ffb7e63421a13f55b38b89 (diff)
downloadtcl-5528e1c1a25f45988be72e2e16ff577f0dbb1abd.zip
tcl-5528e1c1a25f45988be72e2e16ff577f0dbb1abd.tar.gz
tcl-5528e1c1a25f45988be72e2e16ff577f0dbb1abd.tar.bz2
Fix [6f2f83cc149e9918884faffefebc8dfa695f4ea0|6f2f83cc14]: tclWinload.c robustness. And fix a minor possible memory leak in TclSetupEnv() as well. Thanks to Christian Werner for both suggestions, backported from Androwish.
Diffstat (limited to 'win')
-rw-r--r--win/tclWinLoad.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/win/tclWinLoad.c b/win/tclWinLoad.c
index 3ad6328..2946ea2 100644
--- a/win/tclWinLoad.c
+++ b/win/tclWinLoad.c
@@ -63,7 +63,7 @@ TclpDlopen(
* file. */
int flags)
{
- HINSTANCE hInstance;
+ HINSTANCE hInstance = NULL;
const TCHAR *nativeName;
Tcl_LoadHandle handlePtr;
DWORD firstError;
@@ -75,7 +75,10 @@ TclpDlopen(
*/
nativeName = Tcl_FSGetNativePath(pathPtr);
- hInstance = LoadLibraryEx(nativeName,NULL,LOAD_WITH_ALTERED_SEARCH_PATH);
+ if (nativeName != NULL) {
+ hInstance = LoadLibraryEx(nativeName, NULL,
+ LOAD_WITH_ALTERED_SEARCH_PATH);
+ }
if (hInstance == NULL) {
/*
* Let the OS loader examine the binary search path for whatever
@@ -89,7 +92,8 @@ TclpDlopen(
* Remember the first error on load attempt to be used if the
* second load attempt below also fails.
*/
- firstError = GetLastError();
+ firstError = (nativeName == NULL) ?
+ ERROR_MOD_NOT_FOUND : GetLastError();
nativeName = Tcl_WinUtfToTChar(Tcl_GetString(pathPtr), -1, &ds);
hInstance = LoadLibraryEx(nativeName, NULL,