On Wed, 1 Apr 2026 17:19:57 GMT, Kevin Rushforth <[email protected]> wrote:
> This PR fixes a bug in `GlassViewDelegate::convertNSStringToJString` where it > can return an uninitialized `jstring` value in one case. > > The macOS `convertNSStringToJString` function defines a local `jstring jStr` > variable and returns it from the function. This variable is not initialized > in one code path if the call to malloc fails, so garbage can be returned. > Additionally, the length parameter isn't validated and could overflow. > > The fix for the first problem is to initialize the `jStr` variable to `NULL`, > which will be used as the return value in the case where the malloc fails > (the caller already handles a `NULL` return value). The fix for the second is > a simple check to ensure the value passed to malloc does not overflow. For > good measure, I explicitly cast length to (size_t) although that isn't > strictly necessary. Marked as reviewed by jdv (Committer). ------------- PR Review: https://git.openjdk.org/jfx/pull/2135#pullrequestreview-4048191887
