From: Gurusamy Sarathy Date: Mon, 9 Oct 2000 18:30:09 +0000 (+0000) Subject: on Windows, LoadLibrary() could load an extension DLL multiple X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=32f99636ca70a0114499260dd425570a227647eb;p=p5sagit%2Fp5-mst-13.2.git on Windows, LoadLibrary() could load an extension DLL multiple times if forward slashes are used in the path p4raw-id: //depot/perl@7171 --- diff --git a/win32/win32.c b/win32/win32.c index 67e8952..65d5f66 100644 --- a/win32/win32.c +++ b/win32/win32.c @@ -3564,6 +3564,25 @@ win32_dynaload(const char* filename) { dTHXo; HMODULE hModule; + char buf[MAX_PATH+1]; + char *first; + + /* LoadLibrary() doesn't recognize forward slashes correctly, + * so turn 'em back. */ + first = strchr(filename, '/'); + if (first) { + STRLEN len = strlen(filename); + if (len <= MAX_PATH) { + strcpy(buf, filename); + filename = &buf[first - filename]; + while (*filename) { + if (*filename == '/') + *(char*)filename = '\\'; + ++filename; + } + filename = buf; + } + } if (USING_WIDE()) { WCHAR wfilename[MAX_PATH+1]; A2WHELPER(filename, wfilename, sizeof(wfilename));