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

const ResourceHashTableBase leaks mutable reference to elements

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 21
    • hotspot

      The current definition of ResourceHashTableBase::get is const, but returns V*, i.e. a mutable pointer to one of the values it stores.

      This means that, even for a const ResourceHashTable(Base), the elements can be modified through the mutable pointer returned by get.

      Suggested fix is to make the current get implementation non-const, and then add a const overload that returns a const V* instead.

      A mutable reference to the elements can also be leaked through one of the variants of the 'iterate' function. This function is also marked const, but passes mutable references to the keys and values to a callback.

            jvernee Jorn Vernee
            jvernee Jorn Vernee
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: