- yaz_log(YLOG_LOG, "Adding " ODR_INT_PRINTF "+" ODR_INT_PRINTF
- " records to cache %p",
- *req->resultSetStartPoint,
- *f_resp->numberOfRecordsReturned,
- &found_set->m_record_cache);
- found_set->m_record_cache.add(
- odr,
- b_resp->records->u.databaseOrSurDiagnostics,
- *req->resultSetStartPoint,
- *f_resp->numberOfRecordsReturned);
+ Z_NamePlusRecordList *npr =
+ b_resp->records->u.databaseOrSurDiagnostics;
+ // record_cache.add types are int's. Avoid non-fitting values
+ if (*req->resultSetStartPoint > 0
+ && npr->num_records + *req->resultSetStartPoint < INT_MAX)
+ {
+#if 0
+ yaz_log(YLOG_LOG, "Adding " ODR_INT_PRINTF "+" ODR_INT_PRINTF
+ " records to cache %p",
+ *req->resultSetStartPoint,
+ *f_resp->numberOfRecordsReturned,
+ &found_set->m_record_cache);
+#endif
+ found_set->m_record_cache.add(
+ odr, npr, *req->resultSetStartPoint,
+ p_req->recordComposition);
+ }