fix: 修复futime提示错误22的BUG

调用futime时,系统调用接口函数直接使用了file结构体的f_path字段,该字段在退出前被错误地释放了。
避免该问题需要拷贝一份路径

Signed-off-by: Far <yesiyuan2@huawei.com>
Change-Id: Ic0f8e608363da3ed15e252a3f91c46e8397c245e
This commit is contained in:
Far 2022-01-11 16:03:17 +08:00
parent 88a0caae24
commit 8e6f3f1bfb
1 changed files with 4 additions and 1 deletions

View File

@ -118,7 +118,10 @@ static int GetFullpathNull(int fd, const char *path, char **filePath)
if (ret < 0) {
return -get_errno();
}
fullPath = file->f_path;
fullPath = strdup(file->f_path);
if (fullPath == NULL) {
ret = -ENOMEM;
}
} else {
ret = GetFullpath(fd, path, &fullPath);
if (ret < 0) {