summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAllen Winter <allen.winter@kdab.com>2021-09-22 10:08:43 -0400
committerGitHub <noreply@github.com>2021-09-22 10:08:43 -0400
commit262c1b6abcb1ad2a92068e3da9ee313f402f2efe (patch)
treef072c9da1a8a985529a6567d687c37b89971812e /src
parent9e449322c77fa4a859b937f8d5e0380a92865dce (diff)
parent282a3bcb4c5e97e1faf12684d1a984e2319ad865 (diff)
downloadlibical-git-262c1b6abcb1ad2a92068e3da9ee313f402f2efe.tar.gz
Merge pull request #509 from libical/rscale_tzid_fix
Prevent crash when looking for tzid in initialize_rscale()
Diffstat (limited to 'src')
-rw-r--r--src/libical/icalrecur.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/libical/icalrecur.c b/src/libical/icalrecur.c
index dd129bf3..d0f03777 100644
--- a/src/libical/icalrecur.c
+++ b/src/libical/icalrecur.c
@@ -1451,9 +1451,18 @@ static int initialize_rscale(icalrecur_iterator *impl)
UChar *tzid = (UChar *) UCAL_UNKNOWN_ZONE_ID;
short is_hebrew = 0;
- if (dtstart.zone) {
- /* Convert the UTF8 timezoneid of dstart to ICU UChar. */
- const char *src = icaltimezone_get_tzid((icaltimezone *) dtstart.zone);
+ /* Convert the UTF8 timezoneid of dstart to ICU UChar. */
+ const char *src = icaltimezone_get_location((icaltimezone *) dtstart.zone);
+ if (!src) {
+ const char *prefix = icaltimezone_tzid_prefix();
+
+ src = icaltimezone_get_tzid((icaltimezone *) dtstart.zone);
+ if (src && !strncmp(src, prefix, strlen(prefix))) {
+ /* Skip past our prefix */
+ src += strlen(prefix);
+ }
+ }
+ if (src) {
size_t len = (strlen(src) + 1) * U_SIZEOF_UCHAR;
tzid = icalmemory_tmp_buffer(len);
tzid = u_strFromUTF8Lenient(tzid, (int32_t)len, NULL, src, -1, &status);