From 54e2b815ecef2c8a7811d1db3ec3f87950c31872 Mon Sep 17 00:00:00 2001 From: Frederic Culot Date: Fri, 4 Apr 2008 21:31:20 +0000 Subject: no more segfault when changing item priority (fixes Debian Bug #469297) --- src/todo.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/todo.c') 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); } -- cgit v1.2.3-54-g00ecf