src/windows/back/linker_md.c

Print this page
rev 6641 : [mq]: PrivateTransportTest

@@ -42,30 +42,35 @@
                            const char* pname, const char* fname) {
     // Based on os_windows.cpp
 
     char *path_sep = PATH_SEPARATOR;
     char *pathname = (char *)pname;
+    *buffer = '\0';
     while (strlen(pathname) > 0) {
         char *p = strchr(pathname, *path_sep);
         if (p == NULL) {
             p = pathname + strlen(pathname);
         }
         /* check for NULL path */
         if (p == pathname) {
             continue;
         }
         if (*(p-1) == ':' || *(p-1) == '\\') {
-            (void)_snprintf(buffer, buflen, "%.*s%s.dll", (p - pathname),
+            (void)_snprintf(buffer, buflen, "%.*s%s.dll", (int)(p - pathname),
                             pathname, fname);
         } else {
-            (void)_snprintf(buffer, buflen, "%.*s\\%s.dll", (p - pathname),
+            (void)_snprintf(buffer, buflen, "%.*s\\%s.dll", (int)(p - pathname),
                             pathname, fname);
         }
         if (_access(buffer, 0) == 0) {
             break;
         }
+        if (*p == '\0') {
+            pathname = p;
+        } else {
         pathname = p + 1;
+        }
         *buffer = '\0';
     }
 }
 
 /*