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/calcurse.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/calcurse.c')
-rw-r--r-- | src/calcurse.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/src/calcurse.c b/src/calcurse.c index c0d9624..89710af 100644 --- a/src/calcurse.c +++ b/src/calcurse.c @@ -49,6 +49,15 @@ int count, reg; static void do_storage(int day_changed) { struct day_item *day = ui_day_selitem(); + union aptev_ptr item; + + if (day) { + /* + * day_process_storage() rebuilds the vector of day items, so + * we need to save the reference to the actual item here. + */ + item = day->item; + } day_process_storage(ui_calendar_get_slctd_day(), day_changed); ui_day_load_items(); @@ -56,7 +65,7 @@ static void do_storage(int day_changed) if (day_changed) ui_day_sel_reset(); else if (day) - ui_day_set_selitem(day); + ui_day_set_selitem_by_aptev_ptr(item); } static inline void key_generic_change_view(void) |