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

Repeatable crash on typein. #6755

Closed
Andreya-Autumn opened this issue Dec 20, 2022 · 3 comments · Fixed by #6756
Closed

Repeatable crash on typein. #6755

Andreya-Autumn opened this issue Dec 20, 2022 · 3 comments · Fixed by #6756
Labels
Bug Report Item submitted using the Bug Report template

Comments

@Andreya-Autumn
Copy link
Collaborator

Open any typein field.
Type something that starts with a letter.
Hit Enter.
Hard Crash.
Typein crash.txt

@Andreya-Autumn Andreya-Autumn added the Bug Report Item submitted using the Bug Report template label Dec 20, 2022
@baconpaul
Copy link
Collaborator

Oooh ... @mkruselj did you change std::atof(s.c_str()) to std::stof?

If so they have different behaviors. namely std::atof("Hello") returns 0 and std::stof(std::string("yellow")) throws an exception which if not caught will crash the entire system.

I'm sorry i didn't catch this in review but it very much looks like the problem here.

The solution is either

1: use std::atof(s.c_str()) or
2: use auto v = 0.f; try { v = std::stof(s); } catch (const std::invalid_argument &) {}

@mkruselj
Copy link
Collaborator

Thanks! That's exactly what happened, I used stof.

@baconpaul
Copy link
Collaborator

Great. I think solution 1 is the right one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Report Item submitted using the Bug Report template
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants