Commit: bc0ff7dbd6d4725f8a07c65139ce464b6454591a
Parent: b2ee5d2e1cd45f0de824e032a2a8dc01592a41aa
Author: Randy Palamar
Date: Fri, 20 Oct 2023 06:31:22 -0600
properly clear block when its length changes to 0
Diffstat:
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/status.c b/status.c
@@ -35,8 +35,11 @@ static void
updateblock(struct Block *b)
{
b->len = b->fn(b);
- if (memcmp(b->curstr, b->prevstr, b->len)) {
- memcpy(b->prevstr, b->curstr, b->len);
+ if (b->len == 0 || memcmp(b->curstr, b->prevstr, b->len)) {
+ if (b->len == 0)
+ b->prevstr[0] = b->curstr[0] = 0;
+ else
+ memcpy(b->prevstr, b->curstr, b->len);
if (!dirty || b < dirty)
dirty = b;
}