Bug 1553808 - Update libical from upstream. r+a=philipp
authorGeoff Lankow <geoff@darktrojan.net>
Wed, 05 Jun 2019 14:18:14 +1200
changeset 34657 6966f13f07d838cd811dbe70abc61b0070808ee3
parent 34656 671757465ce376c9b238b1969c7fe2d6f5489386
child 34658 c40ad6602e65fa63674ee9c3cce0ca26fa96104a
push id2418
push usermozilla@jorgk.com
push dateTue, 11 Jun 2019 17:56:46 +0000
treeherdercomm-beta@b5d1bd2e6aae [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1553808
Bug 1553808 - Update libical from upstream. r+a=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);
 }