From 6a81502c9686624f3b39a870895be7447f476cdd Mon Sep 17 00:00:00 2001 From: Bron Gondwana Date: Thu, 24 Nov 2016 11:58:17 +1100 Subject: [PATCH] icalvalue: return "" for NO_VALUE if ALLOW_EMPTY_PROPERTIES=true --- src/libical/icalproperty.c | 5 +++++ src/libical/icalvalue.c | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/src/libical/icalproperty.c b/src/libical/icalproperty.c index 66e2fd2a6..6cf4bf9d2 100644 --- a/src/libical/icalproperty.c +++ b/src/libical/icalproperty.c @@ -349,6 +349,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 3e6ef8c78..1e5b01893 100644 --- a/src/libical/icalvalue.c +++ b/src/libical/icalvalue.c @@ -1233,7 +1233,14 @@ char *icalvalue_as_ical_string_r(const icalvalue *value) case ICAL_NO_VALUE: 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 } } }