aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui-day.c
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@calcurse.org>2016-09-27 18:52:13 +0200
committerLukas Fleischer <lfleischer@calcurse.org>2016-09-28 19:02:04 +0200
commitab9256adf082ce78cfb39eb246323e57b846a7a4 (patch)
tree88fe7eb9dd40dfad8117988f9cd5f908dcb91c49 /src/ui-day.c
parent77d5b10ee0d6fc9f000d9ebf523995a7ae7d98bf (diff)
downloadcalcurse-ab9256adf082ce78cfb39eb246323e57b846a7a4.tar.gz
calcurse-ab9256adf082ce78cfb39eb246323e57b846a7a4.zip
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>
Diffstat (limited to 'src/ui-day.c')
-rw-r--r--src/ui-day.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/ui-day.c b/src/ui-day.c
index 6eb055e..c8a4420 100644
--- a/src/ui-day.c
+++ b/src/ui-day.c
@@ -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)