On Wed, 5 Aug 2026 15:11:45 GMT, Matthias Baesken <[email protected]> wrote:
> Seems there is some issue with this GlobalUnlock call
>
> ```
> jbyte *pFileListWithDoubleZeroTerminator = (jbyte
> *)::GlobalLock(glob);
> if (pFileListWithDoubleZeroTerminator == NULL) {
> OLE_HRT(E_INVALIDARG);
> }
> env->SetByteArrayRegion(bytes, 0, st.cbSize.LowPart,
> pFileListWithDoubleZeroTerminator);
> ::GlobalUnlock(pFileListWithDoubleZeroTerminator);
> ```
>
> Shouldn't GlobalUnlock be called on the handle (glob) and NOT on the pointer
> (`pFileListWithDoubleZeroTerminator` ) ?
Yes, the current code looks wrong.
It probably isn't going to cause any functional issues, but it likely prevents
the memory from ever being freed, because it is used in CreateStreamOnHGlobal()
which requires a movable handle, so the value is not going to be recognized by
GlobalUnlock
-------------
PR Comment: https://git.openjdk.org/jdk/pull/32206#issuecomment-5195699817