aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFrederic Culot <calcurse@culot.org>2006-09-02 09:20:35 +0000
committerFrederic Culot <calcurse@culot.org>2006-09-02 09:20:35 +0000
commitcc95f9f8ef05048854230a54491a932e4e611efa (patch)
tree26d34f67d956ef745715fd8161ca1c2b8c5f5995 /src
parent8b6943cc2c079604fc297f399a11b00727b637a5 (diff)
downloadcalcurse-cc95f9f8ef05048854230a54491a932e4e611efa.tar.gz
calcurse-cc95f9f8ef05048854230a54491a932e4e611efa.zip
fixed a possible infinite loop in todo_get_position()
Diffstat (limited to 'src')
-rwxr-xr-xsrc/todo.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/src/todo.c b/src/todo.c
index 385acc7..3337187 100755
--- a/src/todo.c
+++ b/src/todo.c
@@ -1,4 +1,4 @@
-/* $calcurse: todo.c,v 1.3 2006/08/31 18:47:54 culot Exp $ */
+/* $calcurse: todo.c,v 1.4 2006/09/02 09:20:35 culot Exp $ */
/*
* Calcurse - text-based organizer
@@ -120,15 +120,23 @@ struct todo_s *todo_get_item(int item_number)
*/
int todo_get_position(struct todo_s *i)
{
- struct todo_s *o = todolist;
- int n = 1;
+ struct todo_s *o;
+ int n = 1, found = 0;
- for (;;) {
- if (o == i) break;
- o = o->next;
+ for (o = todolist; o; o = o->next) {
+ if (o == i) {
+ found = 1;
+ break;
+ }
n++;
}
- return n;
+ if (found) {
+ return n;
+ } else {
+ fputs(_("FATAL ERROR in todo_get_position: todo not found\n"),
+ stderr);
+ exit(EXIT_FAILURE);
+ }
}
/* Change an item priority by pressing '+' or '-' inside TODO panel. */