Fix SEGV in SRU filter (bug #3495).
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 21 Jun 2010 11:14:04 +0000 (13:14 +0200)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 21 Jun 2010 11:14:04 +0000 (13:14 +0200)
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

index 935f8f9..7dd70a8 100644 (file)
@@ -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)
     {