From 9263a36f12d300b625f5dbf6aa2c0f118290e08c Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 21 Jun 2010 13:14:04 +0200 Subject: [PATCH] Fix SEGV in SRU filter (bug #3495). When the sru_z3950 filter received a non-surrogate diagnostic, it produced an uninitialized SRU record list. This is fixed by this commit by simply defaulting number of records in SRU record list to 0 (until all "good" records are received). --- src/filter_sru_to_z3950.cpp | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/filter_sru_to_z3950.cpp b/src/filter_sru_to_z3950.cpp index 935f8f9..7dd70a8 100644 --- a/src/filter_sru_to_z3950.cpp +++ b/src/filter_sru_to_z3950.cpp @@ -254,7 +254,7 @@ void yf::SRUtoZ3950::Impl::sru(mp::Package &package, Z_GDU *zgdu_req) if (ok && sru_pdu_res->u.response->numberOfRecords && *(sru_pdu_res->u.response->numberOfRecords)) - + ok = z3950_present_request(package, odr_en, sru_pdu_res, sr_req); @@ -624,11 +624,8 @@ yf::SRUtoZ3950::Impl::z3950_present_request( max_recs = *sru_pdu_res->u.response->numberOfRecords - start + 1; Z_SRW_searchRetrieveResponse *sru_res = sru_pdu_res->u.response; - // srw'fy number of returned records - sru_res->num_records = max_recs; - sru_res->records = (Z_SRW_record *) odr_malloc(odr_en, - sru_res->num_records - * sizeof(Z_SRW_record)); + sru_res->records = (Z_SRW_record *) + odr_malloc(odr_en, max_recs * sizeof(Z_SRW_record)); int num = 0; while (num < max_recs) { -- 1.7.10.4