< prev index next >

src/java.base/unix/native/libjli/java_md_solinux.c

Print this page
rev 16214 : 8170663: Fix minor issues in corelib and servicabilty coding.
Reviewed-by: dsamersoff, dholmes
Contributed-by: David CARLIER <devnexen@gmail.com>, goetz.lindenmaier@sap.com

@@ -514,46 +514,47 @@
             runpath = getenv(LD_LIBRARY_PATH);
 #endif /* __solaris__ */
 
             /* runpath contains current effective LD_LIBRARY_PATH setting */
 
-            jvmpath = JLI_StringDup(jvmpath);
+            char *new_jvmpath = JLI_StringDup(jvmpath);
             new_runpath_size = ((runpath != NULL) ? JLI_StrLen(runpath) : 0) +
                     2 * JLI_StrLen(jrepath) + 2 * JLI_StrLen(arch) +
 #ifdef AIX
                     /* On AIX we additionally need 'jli' in the path because ld doesn't support $ORIGIN. */
-                    JLI_StrLen(jrepath) + JLI_StrLen(arch) + JLI_StrLen("/lib//jli:") +
+                    JLI_StrLen(jrepath) + JLI_StrLen(arch) + JLI_StrLen("/lib/jli:") +
 #endif
-                    JLI_StrLen(jvmpath) + 52;
+                    JLI_StrLen(new_jvmpath) + 52;
             new_runpath = JLI_MemAlloc(new_runpath_size);
             newpath = new_runpath + JLI_StrLen(LD_LIBRARY_PATH "=");
 
 
             /*
              * Create desired LD_LIBRARY_PATH value for target data model.
              */
             {
                 /* remove the name of the .so from the JVM path */
-                lastslash = JLI_StrRChr(jvmpath, '/');
+                lastslash = JLI_StrRChr(new_jvmpath, '/');
                 if (lastslash)
                     *lastslash = '\0';
 
                 sprintf(new_runpath, LD_LIBRARY_PATH "="
                         "%s:"
                         "%s/lib/%s:"
 #ifdef AIX
                         "%s/lib/%s/jli:" /* Needed on AIX because ld doesn't support $ORIGIN. */
 #endif
                         "%s/../lib/%s",
-                        jvmpath,
+                        new_jvmpath,
                         jrepath, arch,
 #ifdef AIX
                         jrepath, arch,
 #endif
                         jrepath, arch
                         );
 
+                JLI_MemFree(new_jvmpath);
 
                 /*
                  * Check to make sure that the prefix of the current path is the
                  * desired environment variable setting, though the RequiresSetenv
                  * checks if the desired runpath exists, this logic does a more
< prev index next >