aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrederic Culot <calcurse@culot.org>2008-04-04 21:31:20 +0000
committerFrederic Culot <calcurse@culot.org>2008-04-04 21:31:20 +0000
commit54e2b815ecef2c8a7811d1db3ec3f87950c31872 (patch)
tree2d320e9b9af59d4a603fdfa8b627c562f1238f0e
parent7a2a68de27459d3baab0c4fdeba03e7be0e5e47e (diff)
downloadcalcurse-54e2b815ecef2c8a7811d1db3ec3f87950c31872.tar.gz
calcurse-54e2b815ecef2c8a7811d1db3ec3f87950c31872.zip
no more segfault when changing item priority (fixes Debian Bug #469297)
-rwxr-xr-xsrc/todo.c17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/todo.c b/src/todo.c
index cd38001..20a6e5a 100755
--- a/src/todo.c
+++ b/src/todo.c
@@ -1,4 +1,4 @@
-/* $calcurse: todo.c,v 1.19 2008/01/20 10:45:39 culot Exp $ */
+/* $calcurse: todo.c,v 1.20 2008/04/04 21:31:20 culot Exp $ */
/*
* Calcurse - text-based organizer
@@ -202,7 +202,7 @@ todo_delete_note_bynum(unsigned num)
/* Delete an item from the todo linked list. */
static void
-todo_delete_bynum(unsigned num)
+todo_delete_bynum(unsigned num, erase_flag_e flag)
{
unsigned n;
struct todo_s *i, **iptr;
@@ -214,7 +214,7 @@ todo_delete_bynum(unsigned num)
*iptr = i->next;
free(i->mesg);
if (i->note != NULL)
- erase_note(&i->note, ERASE_FORCE);
+ erase_note(&i->note, flag);
free(i);
return;
}
@@ -271,7 +271,7 @@ todo_delete(conf_t *conf)
switch (answer) {
case 't':
- todo_delete_bynum(hilt - 1);
+ todo_delete_bynum(hilt - 1, ERASE_FORCE);
todos--;
if (hilt > 1)
hilt--;
@@ -328,17 +328,20 @@ todo_chg_priority(int action)
backup = todo_get_item(hilt);
strncpy(backup_mesg, backup->mesg, strlen(backup->mesg) + 1);
backup_id = backup->id;
- strncpy(backup_note, backup->note, NOTESIZ + 1);
+ if (backup->note)
+ strncpy(backup_note, backup->note, NOTESIZ + 1);
+ else
+ backup_note[0] = '\0';
if (action == '+') {
(backup_id > 1) ? backup_id-- : do_chg--;
} else if (action == '-') {
(backup_id < 9) ? backup_id++ : do_chg--;
} else { /* NOTREACHED */
fputs(_("FATAL ERROR in todo_chg_priority: no such action\n"),
- stderr);
+ stderr);
}
if (do_chg) {
- todo_delete_bynum(hilt - 1);
+ todo_delete_bynum(hilt - 1, ERASE_FORCE_KEEP_NOTE);
backup = todo_add(backup_mesg, backup_id, backup_note);
hilt = todo_get_position(backup);
}