--- nss/lib/nss/nssinit.c
+++ nss/lib/nss/nssinit.c
@@ -289,7 +289,7 @@

     /* back up to the top of the directory */
     PORT_Memcpy(path, dbpath, path_len);
-    if (path[path_len - 1] != FILE_SEP) {
+    if (path_len == 0 || path[path_len - 1] != FILE_SEP) {
         path[path_len++] = FILE_SEP;
     }
     PORT_Strcpy(&path[path_len], dllname);
