Skip to content
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

Fix loading submap radiation. #36903

Merged
merged 1 commit into from
Jan 10, 2020
Merged

Fix loading submap radiation. #36903

merged 1 commit into from
Jan 10, 2020

Conversation

BevapDin
Copy link
Contributor

@BevapDin BevapDin commented Jan 10, 2020

SUMMARY: None

Fixes #36811.

Fix deserialization of submap radiation:

Check bounds before setting the value.

Edit: removed lots of useless changes.

Check bounds before setting the value.
@ZhilkinSerg ZhilkinSerg added <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` [JSON] Changes (can be) made in JSON Map / Mapgen Overmap, Mapgen, Map extras, Map display labels Jan 10, 2020
@kevingranade kevingranade merged commit 06b4143 into CleverRaven:master Jan 10, 2020
if( rad_cell < SEEX * SEEY ) {
set_radiation( { 0 % SEEX, rad_cell / SEEX }, rad_strength );
rad_cell++;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the old code that used an "array trick" was also transposing the radiation map every time the game is saved and loaded. This fixes that too.

@hexagonrecursion
Copy link
Contributor

I wonder how the game managed to create a save file that triggers this.

@hexagonrecursion
Copy link
Contributor

I wonder how the game managed to create a save file that triggers this.

Never mind. Figured it out. UBSan just didn't like the "array trick".

int x[2][2];
x[0][3] = 1;

@hexagonrecursion
Copy link
Contributor

According to c faq UBSan might technically be right to flag this as UB.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` [JSON] Changes (can be) made in JSON Map / Mapgen Overmap, Mapgen, Map extras, Map display
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Out of bounds index in submap::set_radiation
4 participants