MCJack123 / craftos2

A fast, modern, and feature-filled ComputerCraft emulator written in C++.
https://www.craftos-pc.cc
Other
230 stars 27 forks source link

Creating a computer with an ID greater than 2147483647 causes various problems #350

Closed tomodachi94 closed 5 months ago

tomodachi94 commented 6 months ago

Describe the bug

When creating a computer with, say, ID 2147483648, weird things occur. If the command-line --id flag is used, I get this:

$ craftos --id 2147483648
terminate called after throwing an instance of 'std::out_of_range'
  what():  stoi
zsh: IOT instruction (core dumped)  craftos --id 2147483648

When using attach 2147483648 computer inside of an existing window, a computer with ID -2147483648 is created (emphasis on the negative). This computer is frozen; the user cannot interact with it, and the process must be killed manually.

This seems like an integer overflow bug, but I'm not a C++ developer so I'm not sure.

To Reproduce See above

Expected behavior A clean, human-readable error when a user tries to make a computer with an ID greater than 2147483647 in the CLI and inside of the emulator.

Screenshots image (the strange frozen window)

See also: the error placed above

Environment (please complete the following information):

Additional context N/A