diff options
author | Lukas Fleischer <lfleischer@calcurse.org> | 2016-09-27 18:52:13 +0200 |
---|---|---|
committer | Lukas Fleischer <lfleischer@calcurse.org> | 2016-09-28 19:02:04 +0200 |
commit | ab9256adf082ce78cfb39eb246323e57b846a7a4 (patch) | |
tree | 88fe7eb9dd40dfad8117988f9cd5f908dcb91c49 /src/day.c | |
parent | 77d5b10ee0d6fc9f000d9ebf523995a7ae7d98bf (diff) | |
download | 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/day.c')
-rw-r--r-- | src/day.c | 9 |
1 files changed, 7 insertions, 2 deletions
@@ -695,20 +695,25 @@ int day_paste_item(struct day_item *p, long date) } /* Returns the position corresponding to a given item. */ -int day_get_position(struct day_item *needle) +int day_get_position_by_aptev_ptr(union aptev_ptr aptevp) { int n = 0; VECTOR_FOREACH(&day_items, n) { struct day_item *p = VECTOR_NTH(&day_items, n); /* Compare pointers. */ - if (p->item.ev == needle->item.ev) + if (p->item.ev == aptevp.ev) return n; } return -1; } +int day_get_position(struct day_item *needle) +{ + return day_get_position_by_aptev_ptr(needle->item); +} + /* Returns a structure containing the selected item. */ struct day_item *day_get_item(int item_number) { |