From 329eecdf6d8d1cfce6a762e9826248d1a289eb67 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sun, 26 Apr 2020 02:14:39 -0500 Subject: [PATCH] Bugfix: remove null pointer check from file stat Do not assume that stat was passed as an uninitialized pointer. In the case of passing a class by reference, the stat pointer would be non-zero. This pointer is not dynamically allocated and therefore not an error. The null pointer check is therefore invalid for these cases. --- level_0/f_file/c/file.c | 12 ------------ level_0/f_file/c/file.h | 3 --- 2 files changed, 15 deletions(-) diff --git a/level_0/f_file/c/file.c b/level_0/f_file/c/file.c index ba11cfd..33d8259 100644 --- a/level_0/f_file/c/file.c +++ b/level_0/f_file/c/file.c @@ -292,10 +292,6 @@ extern "C" { #ifndef _di_f_file_stat_ f_return_status f_file_stat(const f_string file_name, struct stat *file_stat) { - if (file_stat != 0) { - return f_none; - } - if (stat(file_name, file_stat) < 0) { if (errno == ENAMETOOLONG || errno == EFAULT) { return f_status_set_error(f_invalid_name); @@ -332,10 +328,6 @@ extern "C" { if (file_id <= 0) return f_status_set_error(f_invalid_parameter); #endif // _di_level_0_parameter_checking_ - if (file_stat != 0) { - return f_none; - } - int result = fstatat(file_id, file_name, file_stat, flags); if (result < 0) { if (errno == ENAMETOOLONG || errno == EFAULT) { @@ -373,10 +365,6 @@ extern "C" { if (file_id <= 0) return f_status_set_error(f_invalid_parameter); #endif // _di_level_0_parameter_checking_ - if (file_stat != 0) { - return f_none; - } - int result = fstat(file_id, file_stat); if (result < 0) { if (errno == ENAMETOOLONG || errno == EFAULT) { diff --git a/level_0/f_file/c/file.h b/level_0/f_file/c/file.h index 29c755d..bd345fb 100644 --- a/level_0/f_file/c/file.h +++ b/level_0/f_file/c/file.h @@ -382,7 +382,6 @@ extern "C" { * * @return * f_none on success. - * f_none is returned if file_stat has a non-zero address. * f_none_on_eof on success and EOF was reached. * f_file_not_open (with error bit) if file is not open. * f_file_error_read (with error bit) if file read failed. @@ -407,7 +406,6 @@ extern "C" { * * @return * f_none on success. - * f_none is returned if file_stat has a non-zero address. * f_none_on_eof on success and EOF was reached. * f_file_not_open (with error bit) if file is not open. * f_file_error_seek (with error bit) if file seek failed. @@ -437,7 +435,6 @@ extern "C" { * * @return * f_none on success. - * f_none is returned if file_stat has a non-zero address. * f_invalid_name (with error bit) if the name is somehow invalid. * f_out_of_memory (with error bit) if out of memory. * f_number_overflow (with error bit) on overflow error. -- 1.8.3.1