!1730 fix gstrace工具指定无效输出路径判断出错

Merge pull request !1730 from wenkeyang_abab/gstrace_fopen_fix
This commit is contained in:
opengauss-bot
2022-06-29 01:35:41 +00:00
committed by Gitee

View File

@ -1158,7 +1158,7 @@ FILE* trace_fopen(const char* open_file, const char* mode)
canonicalize_path(file_name);
fp = fopen(file_name, mode);
if (chmod(file_name, S_IWUSR | S_IRUSR) != 0) {
if (fp != NULL && chmod(file_name, S_IWUSR | S_IRUSR) != 0) {
fclose(fp);
return NULL;
}