From 7f8731561e102ef0ae53737f5b8aba761b3cf7bf Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Fri, 21 Jan 2011 12:32:38 +0100 Subject: [PATCH] Avoid SEGV for cmd=record in case of no search --- src/session.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/session.c b/src/session.c index 93b25ce..04807a8 100644 --- a/src/session.c +++ b/src/session.c @@ -844,22 +844,25 @@ struct record_cluster *show_single_start(struct session *se, const char *id, struct record_cluster **prev_r, struct record_cluster **next_r) { - struct record_cluster *r; + struct record_cluster *r = 0; session_enter(se); - reclist_enter(se->reclist); *prev_r = 0; *next_r = 0; - while ((r = reclist_read_record(se->reclist))) + if (se->reclist) { - if (!strcmp(r->recid, id)) + reclist_enter(se->reclist); + while ((r = reclist_read_record(se->reclist))) { - *next_r = reclist_read_record(se->reclist); - break; + if (!strcmp(r->recid, id)) + { + *next_r = reclist_read_record(se->reclist); + break; + } + *prev_r = r; } - *prev_r = r; + reclist_leave(se->reclist); } - reclist_leave(se->reclist); if (!r) session_leave(se); return r; -- 1.7.10.4