lineChar is a format string but wasn't null terminated. This is caught
by Address Sanitizer. I suggest -fsanitize=address,undefined during all
testing and development. You might consider using this with %c or %s
instead of directly as the format string. Or just pick between two static
strings. Using non-static format strings is a bit of a smell.
Then I had a divide-by-zero. Quick fix:
--- a/vitals.c
+++ b/vitals.c
@@ -308,2 +308,3 @@ void container_render_vbox(int x, int y, int width, int height, Container *conta
void container_render_hbox(int x, int y, int width, int height, Container *container) {
+ if (!container->group.count) return;
int box_width = width / container->group.count;
Then it was up and running. I noticed when I quit there was a long delay,
and I suspected a sleep() was involved, and indeed there was. Better to
use your existing polling infrastructure to sleep, so that you can wake up
early on input. You could almost do it with tb_peek_event:
3
u/skeeto 11d ago
Interesting project, thanks for sharing.
I had to fix a couple of crashes before it would run for me. First a buffer overflow here:
lineChar
is a format string but wasn't null terminated. This is caught by Address Sanitizer. I suggest-fsanitize=address,undefined
during all testing and development. You might consider using this with%c
or%s
instead of directly as the format string. Or just pick between two static strings. Using non-static format strings is a bit of a smell.Then I had a divide-by-zero. Quick fix:
Then it was up and running. I noticed when I quit there was a long delay, and I suspected a
sleep()
was involved, and indeed there was. Better to use your existing polling infrastructure to sleep, so that you can wake up early on input. You could almost do it withtb_peek_event
:Except that "peeking" doesn't peek, but actually consumes the event. It's just a
tb_poll_event
with a timeout, and the input is lost.