Project

General

Profile

Actions

Bug #2441

open

ai/default: Clean up on every early return from cityresult_fill()

Added by Sweet Tea Dorminy 1 day ago. Updated about 2 hours ago.

Status:
In Review
Priority:
Low
Category:
AI
Target version:
Start date:
11/02/2026
Due date:
% Done:

0%

Estimated time:

Description

cityresult_fill() switches the player's government to the goal government and, for a virtual city, temporarily gives the center tile to the player.
The restore is only at the end of the function; three early returns missed it.
The missing-city-center assert path leaks the result and the virtual city, and leaves the government and tile owner changed.
Te "all tiles worked" return leaves the government changed.
The final sanity asserts leak the result.

In practice the first two paths are unreachable (the center is always iterated, and best_other takes the first non-center tile whatever its value), so this is just a bug on assert paths rather than a live one.
The patch makes every return do the right thing.
Found while reading the code for #2440.


Files

Actions #1

Updated by Marko Lindqvist about 2 hours ago

  • Category set to AI
  • Status changed from New to In Review
  • Assignee set to Marko Lindqvist
  • Target version set to 3.4.0
Actions

Also available in: Atom PDF