Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8259577

Dangling reference to temp_path in Java_sun_tools_attach_VirtualMachineImpl_getTempDir

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8, 11, 16, 17
    • Fix Version/s: 17
    • Component/s: core-svc
    • Subcomponent:
    • Resolved In Build:
      b13

      Description

      SonarCloud instance reports the issue here:

          static char *temp_path = NULL;
          char temp_path_storage[PATH_MAX];
          if (temp_path == NULL) {
              int pathSize = confstr(_CS_DARWIN_USER_TEMP_DIR, temp_path_storage, PATH_MAX);
              if (pathSize == 0 || pathSize > PATH_MAX) {
                  strlcpy(temp_path_storage, "/tmp", sizeof(temp_path_storage));
              }
              temp_path = temp_path_storage; // <---- ERROR
          }
          return JNU_NewStringPlatform(env, temp_path);

      "Address of stack memory associated with local variable 'temp_path_storage' is still referred to by the static variable 'temp_path' upon returning to the caller. This will be a dangling reference"

      Seems to exist since:
       7113349: Initial changeset for Macosx port to jdk

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              kevinw Kevin Walls
              Reporter:
              shade Aleksey Shipilev
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: