LWJGL / lwjgl3

LWJGL is a Java library that enables cross-platform access to popular native APIs useful in the development of graphics (OpenGL, Vulkan, bgfx), audio (OpenAL, Opus), parallel computing (OpenCL, CUDA) and XR (OpenVR, LibOVR, OpenXR) applications.
https://www.lwjgl.org
BSD 3-Clause "New" or "Revised" License
4.76k stars 636 forks source link

Crash with short module name in Library.detectPlatformMismatch() #794

Closed code-disaster closed 2 years ago

code-disaster commented 2 years ago

Version

3.3.1

Platform

Windows x64

JDK

Corretto 1.8.0_302 (bundled with IntelliJ)

Module

LWJGL core

Bug description

I'm (ab-)using Library.loadSystem() to load shared libraries. When passing an empty (or short) module name parameter, a call to detectPlatformMismatch() will crash because the substring() call in its first code line will be out of bounds.

The name must be shorter than "org.lwjgl." and different to "org.lwjgl" for the crash to happen. Also, can only occur after loading the library has failed already.

Stacktrace or crash log output

No response

Spasi commented 2 years ago

Thanks @code-disaster, detectPlatformMismatch will ignore non-LWJGL modules in the next 3.3.2 snapshot.

Spasi commented 2 years ago

LWJGL 3.3.2 snapshot 3 is now available, could you please verify that it now works for you?

code-disaster commented 2 years ago

Yes, works. No more crashes. Now prints an error message and throws UnsatisfiedLinkError.