You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tmux/SOURCES/0002-Close-file-stream-on-e...

33 lines
838 B

From b4ae1931b2170d783f9a946e6f1983e3d0976107 Mon Sep 17 00:00:00 2001
From: Josh Boyer <jwboyer@redhat.com>
Date: Fri, 7 Apr 2023 11:33:56 -0400
Subject: [PATCH 02/12] Close file stream on error
---
file.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/file.c b/file.c
index 974c8a37..9368b4f4 100644
--- a/file.c
+++ b/file.c
@@ -391,6 +391,7 @@ file_read(struct client *c, const char *path, client_file_cb cb, void *cbdata)
size = fread(buffer, 1, sizeof buffer, f);
if (evbuffer_add(cf->buffer, buffer, size) != 0) {
cf->error = ENOMEM;
+ fclose(f);
goto done;
}
if (size != sizeof buffer)
@@ -398,6 +399,7 @@ file_read(struct client *c, const char *path, client_file_cb cb, void *cbdata)
}
if (ferror(f)) {
cf->error = EIO;
+ fclose(f);
goto done;
}
fclose(f);
--
2.31.1