Skip to content

Fix null outfit gallery observer pointer #4135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 22, 2025

Conversation

Geenz
Copy link
Collaborator

@Geenz Geenz commented May 22, 2025

Fixes a null pointer crash in the outfit gallery I managed to hit on macOS working on some stuff.

@Geenz Geenz requested a review from Copilot May 22, 2025 12:16
@github-actions github-actions bot added the c/cpp label May 22, 2025
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR ensures the mOutfitsObserver member is initialized before any use in updateAddedCategory, preventing a null-pointer crash.

  • Moved observer initialization to the start of updateAddedCategory.
  • Removed the duplicate observer creation block later in the method.

@akleshchev
Copy link
Contributor

Why does this use mOutfitsObserver isntead of inherited mCategoriesObserver?

@Geenz
Copy link
Collaborator Author

Geenz commented May 22, 2025

@akleshchev Not sure - sounds like a good opportunity to consolidate though.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR replaces a dedicated mOutfitsObserver with the shared mCategoriesObserver to prevent null-pointer crashes in the outfit gallery and removes redundant observer management code.

  • Deleted mOutfitsObserver member and its init/cleanup
  • Updated all addCategory/removeCategory calls to use mCategoriesObserver

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
indra/newview/lloutfitgallery.h Removed mOutfitsObserver declaration
indra/newview/lloutfitgallery.cpp Deleted init/remove of old observer and switched calls to mCategoriesObserver
Comments suppressed due to low confidence (2)

indra/newview/lloutfitgallery.cpp:729

  • The destructor no longer unregisters or deletes mCategoriesObserver. Verify that cleanup is handled in the base class or reintroduce proper removal to avoid dangling observers or memory leaks.
LLOutfitGallery::~LLOutfitGallery()

indra/newview/lloutfitgallery.cpp:793

  • Ensure that mCategoriesObserver is initialized and registered with gInventory before use; otherwise these calls may still dereference a null pointer.
mCategoriesObserver->addCategory(cat_id, [this, outfits]()

@Geenz
Copy link
Collaborator Author

Geenz commented May 22, 2025

@akleshchev @maxim-productengine Go ahead and give this a re-review. From my testing, there doesn't seem to be any issues.

@Geenz Geenz merged commit fe55c78 into release/2025.04 May 22, 2025
5 of 6 checks passed
@Geenz Geenz deleted the geenz/mac-outfit-gallery-crash-fix branch May 22, 2025 17:02
@github-actions github-actions bot locked and limited conversation to collaborators May 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants