From 2311cd785ae875965a77d848d3f6ee29258fa0fe Mon Sep 17 00:00:00 2001 From: Daimiao Chen Date: Thu, 22 Jan 2026 11:04:59 -0500 Subject: [PATCH] Guard null callbacks in lfs_dir_fetchmatch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit lfs_dir_fetch relies on an impossible tag match to avoid calling a NULL callback. Add an explicit cb != NULL check in the match path so future refactors don’t risk a NULL function-pointer call. --- lfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lfs.c b/lfs.c index da4bfca4..fce9d3bf 100644 --- a/lfs.c +++ b/lfs.c @@ -1290,7 +1290,7 @@ static lfs_stag_t lfs_dir_fetchmatch(lfs_t *lfs, } // found a match for our fetcher? - if ((fmask & tag) == (fmask & ftag)) { + if ((fmask & tag) == (fmask & ftag) && (cb != NULL)) { int res = cb(data, tag, &(struct lfs_diskoff){ dir->pair[0], off+sizeof(tag)}); if (res < 0) {