Fix out-of-bounds memory access

Do not try to access freed day items. This also fixes unexpected
selection changes after modifying appointments or events.

Signed-off-by: Lukas Fleischer <lfleischer@calcurse.org>
This commit is contained in:
Lukas Fleischer
2016-09-27 18:52:13 +02:00
parent 77d5b10ee0
commit ab9256adf0
4 changed files with 26 additions and 5 deletions

View File

@@ -46,13 +46,18 @@ struct day_item *ui_day_selitem(void)
return day_get_item(listbox_get_sel(&lb_apt));
}
void ui_day_set_selitem(struct day_item *day)
void ui_day_set_selitem_by_aptev_ptr(union aptev_ptr p)
{
int n = day_get_position(day);
int n = day_get_position_by_aptev_ptr(p);
if (n >= 0)
listbox_set_sel(&lb_apt, n);
}
void ui_day_set_selitem(struct day_item *day)
{
ui_day_set_selitem_by_aptev_ptr(day->item);
}
/* Request the user to enter a new time. */
static int day_edit_time(int time, unsigned *new_hour,
unsigned *new_minute)