From 4cd2bfc2c12b981f891d4fa335ce7492cc9141f4 Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Thu, 25 Sep 2025 15:22:19 -0500 Subject: [PATCH] Fixed inverted dir->count check logic Curiously, the logic from 48bd2bf was incorrect, and would allow a commit to be tried if erased _or_ dir->count was at risk of overflow. That is clearly wrong, we should only try to commit if both conditions are met... Found again by dschendt --- lfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lfs.c b/lfs.c index 401c60a2..aecace6c 100644 --- a/lfs.c +++ b/lfs.c @@ -2264,7 +2264,7 @@ static int lfs_dir_relocatingcommit(lfs_t *lfs, lfs_mdir_t *dir, } } - if (dir->erased || dir->count >= 0xff) { + if (dir->erased && dir->count < 0xff) { // try to commit struct lfs_commit commit = { .block = dir->pair[0],