123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- From dc63cf73781f9303ed1f12dc7e4ecfb6f3938f3c Mon Sep 17 00:00:00 2001
- From: dave <dave@slackbuilds.org>
- Date: Sat, 28 Jan 2023 01:51:55 +0000
- Subject: [PATCH] Don't fclose(fp) if it failed to fopen()
- MIME-Version: 1.0
- Content-Type: multipart/mixed; boundary="------------true"
- This is a multi-part message in MIME format.
- --------------true
- Content-Type: text/plain; charset=UTF-8; format=fixed
- Content-Transfer-Encoding: 8bit
- This fixes a segfault in fclose@@GLIBC_2.2.5
- 'calcurse -c /path/to/apts -G' segfaults at first note seen.
- Split the tests @ ical.c:216 into two:
- return if fopen(fp) failed.
- fclose(fp) and return @ EOF.
- Signed-off-by: dave <dave@slackbuilds.org>
- ---
- src/ical.c | 5 ++++-
- 1 file changed, 4 insertions(+), 1 deletion(-)
- --------------true
- Content-Type: text/x-patch; name="0001-Don-t-fclose-fp-if-it-failed-to-fopen.patch"
- Content-Transfer-Encoding: 8bit
- Content-Disposition: attachment; filename="0001-Don-t-fclose-fp-if-it-failed-to-fopen.patch"
- diff --git a/src/ical.c b/src/ical.c
- index 535bca8..4b55343 100644
- --- a/src/ical.c
- +++ b/src/ical.c
- @@ -213,7 +213,10 @@ static void ical_export_note(FILE *stream, char *name)
- int has_desc, has_prop, i;
-
- asprintf(¬e_file, "%s/%s", path_notes, name);
- - if (!(fp = fopen(note_file, "r")) || ungetc(getc(fp), fp) == EOF) {
- + if (!(fp = fopen(note_file, "r"))) {
- + return;
- + }
- + if (ungetc(getc(fp), fp) == EOF) {
- fclose(fp);
- return;
- }
- --------------true--
|