Fix infinite recursion in CTerrainTextureManager::LoadAlphaMap

When an alphamap set fails to load, the code falls back to the
"standard" set, guarded by a comparison of the full VFS path
("art/textures/terrain/alphamaps/standard") against "standard".
That comparison is always true, so a failure to load the standard set
itself recursed unboundedly and crashed with a stack overflow.

Compare the alphaMapType parameter instead, so the fallback happens at
most once and a broken standard set returns the failure iterator as
intended.

Fixes #8975

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
josue 2026-06-12 08:50:03 +02:00
parent 50e1f51755
commit 28811e3850

View file

@ -1,4 +1,4 @@
/* Copyright (C) 2025 Wildfire Games.
/* Copyright (C) 2026 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -207,7 +207,7 @@ CTerrainTextureManager::LoadAlphaMap(const VfsPath& alphaMapType)
LOGERROR("Failed to load alphamap: %s", alphaMapType.string8());
const VfsPath standard("standard");
if (path != standard)
if (alphaMapType != standard)
return LoadAlphaMap(standard);
return m_TerrainAlphas.end();
}