From: Adam Dickmeiss Date: Fri, 21 Jan 2011 11:32:38 +0000 (+0100) Subject: Avoid SEGV for cmd=record in case of no search X-Git-Tag: v1.5.3~9^2 X-Git-Url: http://lists.indexdata.com/cgi-bin?a=commitdiff_plain;h=7f8731561e102ef0ae53737f5b8aba761b3cf7bf;p=pazpar2-moved-to-github.git Avoid SEGV for cmd=record in case of no search --- 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;