# HG changeset patch # User stooke # Date 1572872313 -3600 # Node ID 44d60fc2dd8a2f33924e59d0077c2662fbd028ae # Parent f61eea1869e45b866711deb2f43f70548a2fc6c1 8232973: Potential infinite loop in macOS hotspot agent Reviewed-by: stuefe, cjplummer, sspitsyn diff -r f61eea1869e4 -r 44d60fc2dd8a 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;