X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Fseshigh.c;h=bd1ec843e678c621f11d5014341aaecddce86289;hp=5393e4c6a1c4aa6a59e54974f69cde94644dc8fc;hb=5c0e243664a63c8522d400abbda6dc892cae4349;hpb=ffe862e36b8b60b1197b223cec0b78482cbd7763 diff --git a/src/seshigh.c b/src/seshigh.c index 5393e4c..bd1ec84 100644 --- a/src/seshigh.c +++ b/src/seshigh.c @@ -2088,7 +2088,7 @@ static int process_gdu_response(association *assoc, request *req, Z_GDU *res) */ static int process_z_response(association *assoc, request *req, Z_APDU *res) { - Z_GDU *gres = (Z_GDU *) odr_malloc(assoc->encode, sizeof(*res)); + Z_GDU *gres = (Z_GDU *) odr_malloc(assoc->encode, sizeof(*gres)); gres->which = Z_GDU_Z3950; gres->u.z3950 = res; @@ -2423,13 +2423,19 @@ static Z_Records *pack_records(association *a, char *setname, Odr_int start, (Z_Records *) odr_malloc(a->encode, sizeof(*records)); Z_NamePlusRecordList *reclist = (Z_NamePlusRecordList *) odr_malloc(a->encode, sizeof(*reclist)); - Z_NamePlusRecord **list = - (Z_NamePlusRecord **) odr_malloc(a->encode, sizeof(*list) * toget); records->which = Z_Records_DBOSD; records->u.databaseOrSurDiagnostics = reclist; reclist->num_records = 0; - reclist->records = list; + + if (toget < 0) + return diagrec(a, YAZ_BIB1_PRESENT_REQUEST_OUT_OF_RANGE, 0); + else if (toget == 0) + reclist->records = odr_nullval(); + else + reclist->records = (Z_NamePlusRecord **) + odr_malloc(a->encode, sizeof(*reclist->records) * toget); + *pres = Z_PresentStatus_success; *num = 0; *next = 0;