no more segfault when changing item priority (fixes Debian Bug #469297)
This commit is contained in:
parent
7a2a68de27
commit
54e2b815ec
13
src/todo.c
13
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,7 +328,10 @@ todo_chg_priority(int action)
|
||||
backup = todo_get_item(hilt);
|
||||
strncpy(backup_mesg, backup->mesg, strlen(backup->mesg) + 1);
|
||||
backup_id = backup->id;
|
||||
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 == '-') {
|
||||
@ -338,7 +341,7 @@ todo_chg_priority(int action)
|
||||
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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user