summaryrefslogtreecommitdiff
path: root/src/ui-day.c
diff options
context:
space:
mode:
authorLukas Fleischer <calcurse@cryptocrack.de>2014-06-24 23:45:02 +0200
committerLukas Fleischer <calcurse@cryptocrack.de>2014-06-25 12:35:43 +0200
commit0529b864b0b2ababd799ee18faf486dbcce68b97 (patch)
treee2eb2cc780396a8065221d19a29d756d5cd2bcb7 /src/ui-day.c
parent0b46ad4faaee1ce982a64413b57406e43cb83e88 (diff)
downloadcalcurse-0529b864b0b2ababd799ee18faf486dbcce68b97.zip
Fix segmentation fault
This adds some more accurate checks to avoid a segmentation fault that occurred when accessing a nonexistent item. Fixes GitHub issue #7. Reported-by: Bromind <martin.vassor@hotmail.fr> Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
Diffstat (limited to 'src/ui-day.c')
-rw-r--r--src/ui-day.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/ui-day.c b/src/ui-day.c
index 8c34e77..d6be872 100644
--- a/src/ui-day.c
+++ b/src/ui-day.c
@@ -298,7 +298,7 @@ void ui_day_item_edit(void)
struct apoint *a;
int need_check_notify = 0;
- if (day_item_count() <= 0)
+ if (day_item_count(0) <= 0)
return;
struct day_item *p = day_get_item(listbox_get_sel(&lb_apt));
@@ -412,7 +412,7 @@ void ui_day_item_pipe(void)
int pid;
FILE *fpout;
- if (day_item_count() <= 0)
+ if (day_item_count(0) <= 0)
return;
struct day_item *p = day_get_item(listbox_get_sel(&lb_apt));
@@ -575,7 +575,7 @@ void ui_day_item_delete(unsigned reg)
const int nb_note_choices = 2;
long date = ui_calendar_get_slctd_day_sec();
- if (day_item_count() <= 0)
+ if (day_item_count(0) <= 0)
return;
struct day_item *p = day_get_item(listbox_get_sel(&lb_apt));
@@ -668,7 +668,7 @@ void ui_day_item_repeat(void)
struct recur_apoint *ra;
long until, date;
- if (day_item_count() <= 0)
+ if (day_item_count(0) <= 0)
return;
item_nb = listbox_get_sel(&lb_apt);
@@ -797,7 +797,7 @@ void ui_day_item_cut_free(unsigned reg)
/* Copy an item, so that it can be pasted somewhere else later. */
void ui_day_item_copy(unsigned reg)
{
- if (day_item_count() <= 0 || reg == REG_BLACK_HOLE)
+ if (day_item_count(0) <= 0 || reg == REG_BLACK_HOLE)
return;
struct day_item *item = day_get_item(listbox_get_sel(&lb_apt));
@@ -821,7 +821,7 @@ void ui_day_item_paste(unsigned reg)
void ui_day_load_items(void)
{
- listbox_load_items(&lb_apt, day_item_count());
+ listbox_load_items(&lb_apt, day_item_count(1));
}
void ui_day_sel_reset(void)
@@ -889,7 +889,7 @@ void ui_day_update_panel(int which_pan)
void ui_day_popup_item(void)
{
- if (day_item_count() <= 0)
+ if (day_item_count(0) <= 0)
return;
struct day_item *item = day_get_item(listbox_get_sel(&lb_apt));
@@ -898,7 +898,7 @@ void ui_day_popup_item(void)
void ui_day_flag(void)
{
- if (day_item_count() <= 0)
+ if (day_item_count(0) <= 0)
return;
struct day_item *item = day_get_item(listbox_get_sel(&lb_apt));
@@ -907,7 +907,7 @@ void ui_day_flag(void)
void ui_day_view_note(void)
{
- if (day_item_count() <= 0)
+ if (day_item_count(0) <= 0)
return;
struct day_item *item = day_get_item(listbox_get_sel(&lb_apt));
@@ -916,7 +916,7 @@ void ui_day_view_note(void)
void ui_day_edit_note(void)
{
- if (day_item_count() <= 0)
+ if (day_item_count(0) <= 0)
return;
struct day_item *item = day_get_item(listbox_get_sel(&lb_apt));