Bug 1553808 - Update libical from upstream. r=philipp
authorGeoff Lankow <geoff@darktrojan.net>
Wed, 05 Jun 2019 14:18:14 +1200
changeset 26864 9605974b295d9fc51e196c928ff9895818efd398
parent 26863 02a09c7cc1e384140f9675a9aa3048485f13c519
child 26865 bab0908888b8a7f8399a440bbc345b3d895d68c4
push id16033
push usermozilla@jorgk.com
push dateTue, 11 Jun 2019 16:19:46 +0000
treeherdercomm-central@b27953c5a381 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersphilipp
bugs1553808
Bug 1553808 - Update libical from upstream. r=philipp
calendar/libical/src/libical/icalrecur.c
--- a/calendar/libical/src/libical/icalrecur.c
+++ b/calendar/libical/src/libical/icalrecur.c
@@ -399,20 +399,25 @@ void icalrecur_add_bydayrules(struct ica
 	/* Outlook/Exchange generate "BYDAY=MO, FR" and "BYDAY=2 TH".
 	 * Cope with that.
 	 */
 	if (*t == ' ')
 	    t++;
 
 	wd = icalrecur_string_to_weekday(t);
 
-        if (wd != ICAL_NO_WEEKDAY) {
-            array[i++] = (short) (sign * (wd + 8 * weekno));
-            array[i] = ICAL_RECURRENCE_ARRAY_MAX;
+        /* Sanity check value */
+        if (wd == ICAL_NO_WEEKDAY || weekno >= ICAL_BY_WEEKNO_SIZE) {
+            free(vals_copy);
+            return;
         }
+
+        int position = sign * weekno;
+        array[i++] = (wd + (8 * abs(position))) * ((position < 0) ? -1 : 1);
+        array[i] = ICAL_RECURRENCE_ARRAY_MAX;
     }
 
     free(vals_copy);
 
     sort_bydayrules(parser->rt.by_day, parser->rt.week_start);
 }