summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKen Murchison <murch@fastmail.com>2021-11-18 06:50:17 -0500
committerAllen Winter <allen.winter@kdab.com>2021-11-20 11:47:28 -0500
commit25a9f5c0b59369ba97989297816dac403342b4b6 (patch)
tree57b8e719a17b3c6b342094f6bc3c7fbac1317341
parentdcbe03d0ab2a036cae1a796ab984af9cc615c44f (diff)
downloadlibical-git-25a9f5c0b59369ba97989297816dac403342b4b6.tar.gz
icalcomponent.c: protect against NULL property values
-rw-r--r--src/libical/icalcomponent.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/libical/icalcomponent.c b/src/libical/icalcomponent.c
index ffb58237..1a3655b9 100644
--- a/src/libical/icalcomponent.c
+++ b/src/libical/icalcomponent.c
@@ -2359,6 +2359,12 @@ void icalcomponent_set_due(icalcomponent *comp, struct icaltimetype v)
}
}
+static int strcmpsafe(const char *a, const char *b)
+{
+ return strcmp((a == NULL ? "" : a),
+ (b == NULL ? "" : b));
+}
+
static int prop_compare(void *a, void *b)
{
icalproperty *p1 = (icalproperty*) a;
@@ -2374,8 +2380,8 @@ static int prop_compare(void *a, void *b)
}
if (r == 0) {
- r = strcmp(icalproperty_get_value_as_string(p1),
- icalproperty_get_value_as_string(p2));
+ r = strcmpsafe(icalproperty_get_value_as_string(p1),
+ icalproperty_get_value_as_string(p2));
}
}