aboutsummaryrefslogtreecommitdiff
path: root/src/stdlib/stdlib.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-10-12 14:05:22 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-10-12 14:05:22 -0400
commit3cd3b20f58e9d2c6463d503be09e5d4cfaadee6c (patch)
tree9b7120a4969a38793ecff3aab549b463c7dcf822 /src/stdlib/stdlib.c
parentbd190ac0a84eefa3174c04ce1fe2059aed6f2d1b (diff)
Code cleanup and fixing minor issues
Diffstat (limited to 'src/stdlib/stdlib.c')
-rw-r--r--src/stdlib/stdlib.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/stdlib/stdlib.c b/src/stdlib/stdlib.c
index 0756eab3..5204194b 100644
--- a/src/stdlib/stdlib.c
+++ b/src/stdlib/stdlib.c
@@ -59,7 +59,8 @@ static _Noreturn void signal_handler(int sig, siginfo_t *info, void *userdata) {
public
void tomo_init(void) {
GC_INIT();
- USE_COLOR = getenv("COLOR") ? strcmp(getenv("COLOR"), "1") == 0 : isatty(STDOUT_FILENO);
+ const char *color_env = getenv("COLOR");
+ USE_COLOR = color_env ? strcmp(color_env, "1") == 0 : isatty(STDOUT_FILENO);
if (getenv("NO_COLOR") && getenv("NO_COLOR")[0] != '\0') USE_COLOR = false;
setlocale(LC_ALL, "");
@@ -194,6 +195,7 @@ OptionalText_t ask(Text_t prompt, bool bold, bool force_tty) {
cleanup:
if (out && out != stdout) fclose(out);
if (in && in != stdin) fclose(in);
+ if (line != NULL) free(line);
return ret;
}