Fix NULL-deref in pfs_rename_openfile_locked (#325)

File rename tested, works correctly
This commit is contained in:
Levi Neely 2026-03-03 15:58:07 +01:00 committed by GitHub
parent 6ce166a0a5
commit c03a37527f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 1 deletions

View File

@ -309,8 +309,13 @@ int pfs_rename_openfile_locked(psync_fsfileid_t fileid,
fl->currentfolder =
pfs_task_get_or_create_folder_tasks_locked(folderid);
}
char *newname = putil_strdup(name);
if (!newname) {
pthread_mutex_unlock(&fl->mutex);
return -ENOMEM;
}
free(fl->currentname);
fl->currentname = putil_strdup(name);
fl->currentname = newname;
pthread_mutex_unlock(&fl->mutex);
return 1;
}