From: Adam Dickmeiss Date: Tue, 2 Mar 2010 12:41:54 +0000 (+0100) Subject: GFS present: Deal with number of recs <= 0 X-Git-Tag: v4.0.2~8 X-Git-Url: http://lists.indexdata.dk/?a=commitdiff_plain;h=92e360a6e22fc5fda22d7f6a6449c3c8f0ee8fb9;p=yaz-moved-to-github.git GFS present: Deal with number of recs <= 0 --- diff --git a/src/seshigh.c b/src/seshigh.c index 5393e4c..44d6619 100644 --- a/src/seshigh.c +++ b/src/seshigh.c @@ -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;