8232973: Potential infinite loop in macOS hotspot agent
authorstooke
Mon, 04 Nov 2019 13:58:33 +0100
changeset 58912 44d60fc2dd8a
parent 58910 f61eea1869e4
child 58913 e2dfab7beccb
8232973: Potential infinite loop in macOS hotspot agent Reviewed-by: stuefe, cjplummer, sspitsyn
src/jdk.hotspot.agent/macosx/native/libsaproc/ps_core.c
--- a/src/jdk.hotspot.agent/macosx/native/libsaproc/ps_core.c	Mon Nov 04 11:33:15 2019 +0100
+++ b/src/jdk.hotspot.agent/macosx/native/libsaproc/ps_core.c	Mon Nov 04 13:58:33 2019 +0100
@@ -364,7 +364,8 @@
       strcpy(filepath, java_home);
     } else {
       char* dyldpath = getenv("DYLD_LIBRARY_PATH");
-      char* dypath = strtok(dyldpath, ":");
+      char* save_ptr;
+      char* dypath = strtok_r(dyldpath, ":", &save_ptr);
       while (dypath != NULL) {
         strcpy(filepath, dypath);
         strcat(filepath, filename);
@@ -372,7 +373,7 @@
            strcpy(rpath, filepath);
            return true;
         }
-        dypath = strtok(dyldpath, ":");
+        dypath = strtok_r(NULL, ":", &save_ptr);
       }
       // not found
       return false;