logoalt Hacker News

gavinray04/23/20255 repliesview on HN

Rust protects you from external file data you read being incorrect?

That's one hell of a language!


Replies

ArchOversight04/23/2025

The code would have failed because you can't use an uninitialized variable, so you would have had to set it to a default. You don't just get random garbage from the stack.

show 1 reply
SkiFire1304/23/2025

It would have forced you to either specify a default or fail pretty loudly as soon as you launched the game, both much better than leaving a bug there just for it to resurface 20 years later.

mbel04/23/2025

Most popular languages would prevent this. In this case it’s as simple as having more sensible reader API than sscanf in standard library and forcing variables to be initialized.

stefs04/23/2025

Of course not, but this here was a memory access error and rust would have prevented this.

rs18604/24/2025

You didn't actually understand what the post is about. Maybe read it again.