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

[Presenter] InitGame cause Segmentation fault if game id not exist #41

Open
angtsusiong opened this issue Apr 27, 2024 · 1 comment · May be fixed by #44
Open

[Presenter] InitGame cause Segmentation fault if game id not exist #41

angtsusiong opened this issue Apr 27, 2024 · 1 comment · May be fixed by #44
Labels
bug Something isn't working

Comments

@angtsusiong
Copy link
Contributor

angtsusiong commented Apr 27, 2024

void InitGameUsecase::execute(InitGameRequest& req, Repository& repo, Presenter& presenter)
{
// Find.
auto game = repo.findById(req.id());
if (!game)
{
auto err_event = std::make_shared<InitGameEvent>();
err_event->set_status(StatusCode::BadRequest);
err_event->set_message("Failed to init game because cannot find the game ID !");
log_->error(err_event->message());
presenter.present(err_event.get());
return;
}

private:
StatusCode status_ = StatusCode::NoContent;
std::string message_;
Bank* bank_ = nullptr;
ArchitectureMarket* market_ = nullptr;
PlayerPtrs* players_ = nullptr;
// Player name for the next turn.
std::string player_name_;
};

res["BankBalance"] = std::to_string(bank_->totalCoin());

Some call by nullptr.

@angtsusiong angtsusiong added good first issue Good for newcomers bug Something isn't working and removed good first issue Good for newcomers labels Apr 27, 2024
@angtsusiong
Copy link
Contributor Author

angtsusiong commented Apr 27, 2024

image
image
image

Check nullptr before call solve this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant