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

Unsigned integer overflow with extremely high cargo capacities in refit window #8064

Closed
James103 opened this issue Apr 6, 2020 · 0 comments
Labels
bug Something isn't working component: interface This is an interface issue

Comments

@James103
Copy link
Contributor

James103 commented Apr 6, 2020

Version of OpenTTD

1.10.0 (64 bit Windows 10)
NewGRF: big-train-2\sillytrain.grf version 1 (available as "Big Train" on bananas)

Expected result

No 16-bit unsigned integer overflow takes place when calculating the refit capacity, with a 32-bit integer being used instead. "New capacity: 262,136 passengers"

Actual result

A 16-bit unsigned integer overflow takes place when calculating the refit capacity. "New capacity: 65,528 passengers" (262,136 % 65,536 = 65,528)

image

Steps to reproduce

  1. Build an electric rail depot.
  2. Purchase "Big Train" once. This will refit it to Passengers by default.
  3. Refit the train you purchased. Notice that there are several liveries available for each cargo.
  4. Single-click to select another livery for Passengers, but don't click the refit button.
  5. Look where it says "New capacity" and notice an integer overflow (65,528 passengers).
  6. Click the refit button.
  7. Open the details window of your train, select the Capacities tab.
  8. Notice the correct value of 262,136 passengers is stored as the capacity.
@glx22 glx22 added bug Something isn't working component: interface This is an interface issue labels Apr 6, 2020
glx22 added a commit to glx22/OpenTTD that referenced this issue Apr 6, 2020
@LordAro LordAro closed this as completed in b50d77b Apr 6, 2020
LordAro pushed a commit to LordAro/OpenTTD that referenced this issue Apr 13, 2020
douiwby pushed a commit to douiwby/OpenTTD that referenced this issue Apr 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working component: interface This is an interface issue
Projects
None yet
Development

No branches or pull requests

2 participants