Skip to content

AudioReactive Palettes inconsistent / unsafe behaviour when switching off the usermod temporarily #5681

Description

@softhack007

// add/remove custom/audioreactive palettes
if (prevEnabled && !enabled) removeAudioPalettes();
if (!prevEnabled && enabled) createAudioPalettes();

When the AR usermod is "switched off" (button in info panel, or by unchecking "enabled" in AR settings). audioreactive palettes are erased from the internal palettes vector. If a preset still references an Effect with AR palette, accessing the palette colors reads from unallocated memory - vector array [] access is not checked for bounds violation.

This is inconsistent to other AR effects, which enable Sound Simulation when the AR usermod is off. Its also inconsistent with the original AR palettes behaviour in WLED-MM, where palette colors come from simulation (fftResult[]) when AR is disabled.

usermodPalettes.erase(usermodPalettes.begin() + i);

WLED/wled00/json.cpp

Lines 1014 to 1016 in 4efb02d

} else if (i >= palettesCount) { // usermod palettes (IDs 255, 254, ...)
int umIdx = i - palettesCount;
setPaletteColors(curPalette, usermodPalettes[umIdx].palette);

WLED/wled00/FX_fcn.cpp

Lines 276 to 278 in 4efb02d

default: //progmem palettes
if (pal > WLED_CUSTOM_PALETTE_ID_BASE) { // usermod palette
targetPalette = usermodPalettes[WLED_USERMOD_PALETTE_ID_BASE - pal].palette;

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions