From 5394e981d9b5c25211c9c501af99a34af0c46f71 Mon Sep 17 00:00:00 2001
From: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
Date: Wed, 5 Apr 2023 14:03:07 +0200
Subject: Fix segfault when importing iCal files

Previously, events / appointments without a description resulted in
a segfault. This provides a trivial fix by adding an `<emtpy>` as
description in this case.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
---
 src/ical.c | 8 ++++++++
 1 file changed, 8 insertions(+)

(limited to 'src')

diff --git a/src/ical.c b/src/ical.c
index 535bca8..60f7081 100644
--- a/src/ical.c
+++ b/src/ical.c
@@ -520,6 +520,10 @@ ical_store_event(char *mesg, char *note, time_t day, time_t end,
 	struct event *ev;
 	struct recur_event *rev;
 
+	if (!mesg)
+		mesg = mem_strdup(_("(empty)"));
+	EXIT_IF(!mesg, _("ical_store_event: out of memory"));
+
 	/*
 	 * Repeating event. The end day is ignored, and the event becomes
 	 * one-day even if multi-day.
@@ -572,6 +576,10 @@ ical_store_apoint(char *mesg, char *note, time_t start, long dur,
 	struct recur_apoint *rapt;
 	time_t day;
 
+	if (!mesg)
+		mesg = mem_strdup(_("(empty)"));
+	EXIT_IF(!mesg, _("ical_store_event: out of memory"));
+
 	if (has_alarm)
 		state |= APOINT_NOTIFY;
 	if (rpt) {
-- 
cgit v1.2.3-70-g09d2