From 92e360a6e22fc5fda22d7f6a6449c3c8f0ee8fb9 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Tue, 2 Mar 2010 13:41:54 +0100 Subject: [PATCH] GFS present: Deal with number of recs <= 0 --- src/seshigh.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) 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; -- 1.7.10.4