fix a potential division by zero in GetDefaultWindow(Width|Height)

This commit is contained in:
Sebastian Krzyszkowiak 2019-05-10 23:42:35 +02:00
parent a8f78ea9bb
commit 2b3a2e3d72
No known key found for this signature in database
GPG key ID: E8F235CF3BDBC3FF

View file

@ -32,7 +32,7 @@
static char* GetDefaultWindowWidth(struct Game* game) {
char* buf = malloc(sizeof(char) * 255);
double aspect = game->_priv.params.aspect ? game->_priv.params.aspect : (game->_priv.params.width / (double)game->_priv.params.height);
double aspect = game->_priv.params.aspect ? game->_priv.params.aspect : (game->_priv.params.height ? (game->_priv.params.width / (double)game->_priv.params.height) : 1.0);
if (aspect < 1.0) {
aspect = 1.0;
}
@ -42,7 +42,7 @@ static char* GetDefaultWindowWidth(struct Game* game) {
static char* GetDefaultWindowHeight(struct Game* game) {
char* buf = malloc(sizeof(char) * 255);
double aspect = game->_priv.params.aspect ? game->_priv.params.aspect : (game->_priv.params.width / (double)game->_priv.params.height);
double aspect = game->_priv.params.aspect ? game->_priv.params.aspect : (game->_priv.params.height ? (game->_priv.params.width / (double)game->_priv.params.height) : 1.0);
if (aspect > 1.0) {
aspect = 1.0;
}