From 4ea51eb8374f0353a3098f3c0e5dbfd212c66673 Mon Sep 17 00:00:00 2001 From: Colin Leroy-Mira Date: Wed, 29 Jan 2025 06:00:20 +0100 Subject: [PATCH] fix save logic --- src/mastodon/cli/login.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/mastodon/cli/login.c b/src/mastodon/cli/login.c index bb3f7218..8933a3b2 100644 --- a/src/mastodon/cli/login.c +++ b/src/mastodon/cli/login.c @@ -63,10 +63,18 @@ static int save_settings(void) { r = write(fd, &login_data, sizeof(login_data)); - if (r < 0 || close(fd) != 0) { + if (r != sizeof(login_data)) { + close(fd); +err_close: + clrscr(); dputs("Could not save settings file.\r\n"); + cgetc(); return -1; } + if (close(fd) != 0) { + goto err_close; + } + return 0; }