aboutsummaryrefslogtreecommitdiff
path: root/games/gameclicker.c
diff options
context:
space:
mode:
authordavid <[email protected]>2026-07-23 22:12:42 -0300
committerdavid <[email protected]>2026-07-23 22:12:42 -0300
commit17881c653f333baa15f9e7b735466a0333a6cee6 (patch)
tree851c25695ca2433714383ecf697e2049e2a6c65e /games/gameclicker.c
parent9765de97f1df3bed997eb341172ba4575f5376f3 (diff)
downloadpetratc-17881c653f333baa15f9e7b735466a0333a6cee6.tar.gz
petratc-17881c653f333baa15f9e7b735466a0333a6cee6.zip
fixed a couple bugs
Diffstat (limited to 'games/gameclicker.c')
-rw-r--r--games/gameclicker.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/games/gameclicker.c b/games/gameclicker.c
index 4dff0b6..2ac2ca3 100644
--- a/games/gameclicker.c
+++ b/games/gameclicker.c
@@ -173,7 +173,7 @@ static bignum divmixregbig(bignum a, double regnum){
static char *bignumprint(bignum b) {
//32 bytes is more than enough for 124.24 trillion idk
- char *nice = malloc(32 * sizeof(char));
+ char *nice = malloc(32 * sizeof(char));
if(nice == NULL) return NULL;
if(b.y >= 0 && b.y < 12) {
@@ -181,7 +181,7 @@ static char *bignumprint(bignum b) {
} else{
snprintf(nice, 32, "%.2lfe3*%d", b.x, b.y);
}
- return nice;
+ return nice;
}
@@ -239,8 +239,12 @@ static void drawwin(WINDOW *win, bignum cheeses){
char *scorestr = bignumprint(cheeses);
char scoremsg[64];
- snprintf(scoremsg, sizeof(scoremsg), "cheese: %s", scorestr);
- free(scorestr);
+ if(scorestr != NULL) {
+ snprintf(scoremsg, sizeof(scoremsg), "cheese: %s", scorestr);
+ free(scorestr);
+ } else {
+ snprintf(scoremsg, sizeof(scoremsg), "cheese: ERROR");
+ }
if(mode == layoutwide){
mvwprintw(win, 1, scorecol, "%s", scoremsg);