link #I57H9Z fixed gstrace file open seg fault error

This commit is contained in:
Wenke Yang
2022-05-15 20:58:00 +08:00
parent 6c5898646e
commit 13ca80eecf

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;
}