From 6e2b2cc9c5c0290bf2fc53ff3dab7bf15c97526b Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 12 Mar 2013 14:45:25 +0100 Subject: [PATCH] Avoid null ptr reference of se->reclist PAZ-856 Could happen if show occurs before a search in a session. --- src/session.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/src/session.c b/src/session.c index fbcd94e..50c4b94 100644 --- a/src/session.c +++ b/src/session.c @@ -624,7 +624,6 @@ int session_is_preferred_clients_ready(struct session *s) static void session_clear_set(struct session *se, struct reclist_sortparms *sp) { reclist_destroy(se->reclist); - se->reclist = 0; if (nmem_total(se->nmem)) session_log(se, YLOG_DEBUG, "NMEN operation usage %zd", nmem_total(se->nmem)); @@ -965,7 +964,7 @@ struct session *new_session(NMEM nmem, struct conf_service *service, session->number_of_warnings_unknown_elements = 0; session->number_of_warnings_unknown_metadata = 0; session->num_termlists = 0; - session->reclist = 0; + session->reclist = reclist_create(nmem); session->clients_active = 0; session->clients_cached = 0; session->settings_modified = 0; @@ -1207,22 +1206,19 @@ struct record_cluster *show_single_start(struct session *se, const char *id, session_enter(se, "show_single_start"); *prev_r = 0; *next_r = 0; - if (se->reclist) - { - reclist_limit(se->reclist, se); + reclist_limit(se->reclist, se); - reclist_enter(se->reclist); - while ((r = reclist_read_record(se->reclist))) + reclist_enter(se->reclist); + while ((r = reclist_read_record(se->reclist))) + { + if (!strcmp(r->recid, id)) { - if (!strcmp(r->recid, id)) - { - *next_r = reclist_read_record(se->reclist); - break; - } - *prev_r = r; + *next_r = reclist_read_record(se->reclist); + break; } - reclist_leave(se->reclist); + *prev_r = r; } + reclist_leave(se->reclist); if (!r) session_leave(se, "show_single_start"); return r; -- 1.7.10.4