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

os::build_agent_function_name potentially wastes a byte when allocating the buffer

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Fixed
    • Icon: P4 P4
    • 24
    • None
    • hotspot
    • b27
    • windows

      From the review of JEP 479:

      In src/hotspot/os/windows/os_windows.cpp, around line 5863: https://github.com/openjdk/jdk/pull/21744#discussion_r1828969105

      "[pre-existing, and can't comment on line 5858 because it's not sufficiently near a change.] The calculation of len is wasting a byte when lib_name is null. The +2 accounts for the terminating NUL and the underscore separator between the sym_name part and the lib_name part. That underscore isn't added when there isn't a lib_name part. I think the simplest fix would be to change name_len to (name_len +1) and +2 to +1 in that calculation. And add some
      commentary.
      -----

      The same code pattern exists in os_posix.cpp

      I opted for a solution where name_len always reflects the actual length of the lib name - otherwise we need to subtract the 1 again when doing the strncat. I also made the need for the underscore explicit.

            dholmes David Holmes
            dholmes David Holmes
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: