X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=perl%2Fzebra_api_ext.c;h=49663f47353dbee005a10399bdacaea530f349db;hb=8e1d114f1969b19d12afc6ab0b04031e35ae5c88;hp=32289e98fc34e96d2c34f5088e0b3ef0f5486fb8;hpb=a1dba281bafc701a7e958d6e7512a2dbb3027191;p=idzebra-moved-to-github.git diff --git a/perl/zebra_api_ext.c b/perl/zebra_api_ext.c index 32289e9..49663f4 100644 --- a/perl/zebra_api_ext.c +++ b/perl/zebra_api_ext.c @@ -547,17 +547,22 @@ int sort (ZebraHandle zh, int num_input_setnames = 0; int sort_status = 0; Z_SortKeySpecList *sort_sequence = yaz_sort_spec (stream, sort_spec); - + if (!sort_sequence) { + logf(LOG_WARN,"invalid sort specs '%s'", sort_spec); + zh->errCode = 207; + return (-1); + } + /* we can do this, since the typemap code for char** will put a NULL at the end of list */ - while (input_setnames[num_input_setnames]) num_input_setnames++; - - if (zebra_begin_read (zh)) - return; - - resultSetSort (zh, stream->mem, num_input_setnames, input_setnames, - output_setname, sort_sequence, &sort_status); + while (input_setnames[num_input_setnames]) num_input_setnames++; - zebra_end_read(zh); - return (sort_status); + if (zebra_begin_read (zh)) + return; + + resultSetSort (zh, stream->mem, num_input_setnames, input_setnames, + output_setname, sort_sequence, &sort_status); + + zebra_end_read(zh); + return (sort_status); }