Skip to content

OpenALBindings: fix crash on HL when passing NULL device#1987

Merged
joshtynjala merged 1 commit intoopenfl:developfrom
ACrazyTown:fix/alc-getstring-crash-hl
Oct 14, 2025
Merged

OpenALBindings: fix crash on HL when passing NULL device#1987
joshtynjala merged 1 commit intoopenfl:developfrom
ACrazyTown:fix/alc-getstring-crash-hl

Conversation

@ACrazyTown
Copy link
Contributor

The following code produces an access violation when targeting Hashlink:

import lime.media.openal.ALC;

class Main extends lime.app.Application
{
	public function new()
	{
		super();
		trace(ALC.getString(null, ALC.ALL_DEVICES_SPECIFIER));
	}
}

The OpenAL specification mentions that passing in null to ALC.getString() is allowed in certain cases, so we should handle null gracefully instead of blindly trying to read the pointer.

(...)
Specifying NULL for deviceHandle when asking for ALC_EXTENSIONS will generate
an ALC_INVALID_DEVICE error. The deviceHandle value is ignored when asking for
ALC_DEFAULT_DEVICE_SPECIFIER or
ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER.
(...)
An alcGetString query of ALC_DEVICE_SPECIFIER or
ALC_CAPTURE_DEVICE_SPECIFIER with a NULL device passed in will return a list
of available devices. Each device name will be separated by a single NULL character and
the list will be terminated with two NULL characters.

@joshtynjala joshtynjala merged commit 3643bf0 into openfl:develop Oct 14, 2025
31 checks passed
@joshtynjala
Copy link
Member

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants