Browse Source

file: Fix faux_file_close()

Serj Kalichev 3 months ago
parent
commit
212ce8789b
1 changed files with 6 additions and 8 deletions
  1. 6 8
      faux/file/file.c

+ 6 - 8
faux/file/file.c

@@ -121,21 +121,19 @@ faux_file_t *faux_file_open(const char *pathname, int flags, mode_t mode)
  */
 bool_t faux_file_close(faux_file_t *f)
 {
-	int fd = -1;
+	bool_t rc = BOOL_TRUE;
 
 	if (!f)
 		return BOOL_FALSE;
 
-	fd = f->fd;
-	faux_free(f->buf);
-	faux_free(f);
-
 	if (f->close_file) {
-		if (close(fd) < 0)
-			return BOOL_FALSE;
+		if (close(f->fd) < 0)
+			rc = BOOL_FALSE;
 	}
+	faux_free(f->buf);
+	faux_free(f);
 
-	return BOOL_TRUE;
+	return rc;
 }