Skip to content

Fix uninitialized avatar load result (#1296 regression) - #1373

Merged
complexlogic merged 1 commit into
UltraStar-Deluxe:masterfrom
dgruss:fix-avatar-load-result
Aug 2, 2026
Merged

Fix uninitialized avatar load result (#1296 regression)#1373
complexlogic merged 1 commit into
UltraStar-Deluxe:masterfrom
dgruss:fix-avatar-load-result

Conversation

@dgruss

@dgruss dgruss commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Problem
Since #1296 was merged, TAvatarDatabase.LoadAvatar assigns its class-valued Result only inside a try block. If the database query or a field conversion raises first, the exception is logged and the function returns without an explicit result. A class variable is a reference; declaring it does not construct an object. See the Free Pascal class-instantiation documentation.

Fix

Initialize Result := nil before entering the failure-prone block. This is a one-line change and preserves every successful return path.

Reproduce/verify

Make the avatar query fail (for example, temporarily request a missing/corrupt thumbnail row) and call LoadAvatar. Before the fix the returned reference is not defined by the function; after it the failure contract is deterministically nil. Tested on Windows 11.

@complexlogic
complexlogic merged commit 5623eb3 into UltraStar-Deluxe:master Aug 2, 2026
5 checks passed
@dgruss
dgruss deleted the fix-avatar-load-result branch August 2, 2026 15:23
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