diff options
author | Ken Murchison <murch@fastmail.com> | 2021-11-18 06:50:17 -0500 |
---|---|---|
committer | Allen Winter <allen.winter@kdab.com> | 2021-11-20 11:47:28 -0500 |
commit | 25a9f5c0b59369ba97989297816dac403342b4b6 (patch) | |
tree | 57b8e719a17b3c6b342094f6bc3c7fbac1317341 | |
parent | dcbe03d0ab2a036cae1a796ab984af9cc615c44f (diff) | |
download | libical-git-25a9f5c0b59369ba97989297816dac403342b4b6.tar.gz |
icalcomponent.c: protect against NULL property values
-rw-r--r-- | src/libical/icalcomponent.c | 10 |
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)); } } |