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

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

Signed-off-by: Far <yesiyuan2@huawei.com>
Change-Id: I519ccb38bec323c93aa8cff920143bb3f9931c22
This commit is contained in:
Far 2022-01-11 14:47:05 +08:00
parent c18b51182b
commit f2861ddfb4
1 changed files with 4 additions and 1 deletions

View File

@ -119,7 +119,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) {