about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2020-01-14 20:08:45 -0500
committerJune McEnroe <june@causal.agency>2020-01-14 20:10:20 -0500
commit2ecafb0e4e31c7aa63e5f95fa24dbac10d5c2e8b (patch)
tree2d89c84f0988bce59d469c8437f3e905995e5d94
parentImplement IRC formatting to ANSI translation (diff)
downloadlitterbox-2ecafb0e4e31c7aa63e5f95fa24dbac10d5c2e8b.tar.gz
litterbox-2ecafb0e4e31c7aa63e5f95fa24dbac10d5c2e8b.zip
Ensure ansi resets formatting and null-terminates
fmemopen in text-mode only ensures the buffer is null-terminated if the
last write does not fill the buffer.
-rw-r--r--scoop.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/scoop.c b/scoop.c
index 241ef3e..006a416 100644
--- a/scoop.c
+++ b/scoop.c
@@ -123,8 +123,10 @@ static const char *ansi(const char *str) {
 			}
 		}
 	}
-
+	fprintf(out, "\33[m");
 	fclose(out);
+
+	buf[sizeof(buf) - 1] = '\0';
 	return buf;
 }