diff options
author | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2025-02-24 00:59:39 +0100 |
---|---|---|
committer | Samuel Thibault <samuel.thibault@ens-lyon.org> | 2025-02-24 00:59:39 +0100 |
commit | 9e583f3dcfe5a48e19033362847791c9004574f2 (patch) | |
tree | e90d31cb163f237543487cf2130e8699eea6ce7c | |
parent | 723fd3be917570ec3b2605b2e9c8c4e83a8f78e9 (diff) |
libdiskfs: Avoid putting ref of NULL pointer
E.g in the "Negative lookup cached." error case, diskfs_lookup clears
NP, so we would segfault.
-rw-r--r-- | libdiskfs/dir-renamed.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/libdiskfs/dir-renamed.c b/libdiskfs/dir-renamed.c index 69fd7fe3..f3e1948a 100644 --- a/libdiskfs/dir-renamed.c +++ b/libdiskfs/dir-renamed.c @@ -30,19 +30,20 @@ checkpath(struct node *source, struct protid *cred) { error_t err; - struct node *np; + struct node *np, *newnp; for (np = target, err = 0; /* nothing */; /* This special lookup does a diskfs_nput on its first argument when it succeeds. */ - err = diskfs_lookup (np, "..", LOOKUP | SPEC_DOTDOT, &np, 0, cred)) + err = diskfs_lookup (np, "..", LOOKUP | SPEC_DOTDOT, &newnp, 0, cred)) { if (err) { diskfs_nput (np); return err; } + np = newnp; if (np == source) { |