From 7665d8b2f27a1662f31c4215afcfff325483fda0 Mon Sep 17 00:00:00 2001 From: Bron Gondwana Date: Mon, 27 Jan 2025 11:22:13 +0100 Subject: [PATCH] icalvalue: return "" for NO_VALUE if ALLOW_EMPTY_PROPERTIES=true --- src/libical/icalproperty.c | 5 +++++ src/libical/icalvalue.c | 10 ++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/libical/icalproperty.c b/src/libical/icalproperty.c index 36b7351b9..765cc4970 100644 --- a/src/libical/icalproperty.c +++ b/src/libical/icalproperty.c @@ -341,6 +341,11 @@ const char *icalproperty_as_ical_string(icalproperty *prop) char *buf; buf = icalproperty_as_ical_string_r(prop); +#if ICAL_ALLOW_EMPTY_PROPERTIES + /* empty string is set to no-value, per commit b1a9eb33597028b2d160f289b6105f4aa67276a7 + * which return NULL as the string value. Convert back to an empty string here */ + if (!buf) return ""; +#endif icalmemory_add_tmp_buffer(buf); return buf; } diff --git a/src/libical/icalvalue.c b/src/libical/icalvalue.c index 0f04eee92..305c7a604 100644 --- a/src/libical/icalvalue.c +++ b/src/libical/icalvalue.c @@ -1246,9 +1246,15 @@ char *icalvalue_as_ical_string_r(const icalvalue *value) case ICAL_NO_VALUE: _fallthrough(); - default: { + default: +#if ICAL_ALLOW_EMPTY_PROPERTIES + /* empty string is set to no-value, per + * commit b1a9eb33597028b2d160f289b6105f4aa67276a7 + * Convert back to an empty string here */ + return icalmemory_strdup(""); +#else return 0; - } +#endif } }