|
\*----------------------------------------------------------------------*/
+#include <errno.h>
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
/* Read all the refs for this word */
/* Where do they end? */
fseek( cfp, (int)(inx_start + univ2int(cfh.data_ptr)), SEEK_SET );
- fread( tbuf, 1, rsize, cfp );
+ if (fread( tbuf, 1, rsize, cfp ) < (size_t)rsize)
+ tsl_error(TRUE, "Reading %d refs: %s", rsize, strerror(errno));
/* Process the ref list.
Expand compressed references.
/* Allocate & initialize buffer for strings (all words) */
i=univ2int(cfh.index_ptr) - univ2int(cfh.word_ptr);
cf_words = malloc( i );
- fread( cf_words, 1, i, cfp );
+ if (fread( cf_words, 1, i, cfp ) < (size_t)i)
+ tsl_error( TRUE, "reading initialised buffer for strings");
/* Allocate & initialize buffer for index */
i=univ2int(cfh.data_ptr) - univ2int(cfh.index_ptr);
cf_index = (short int *) malloc( i );
- fread( cf_index, 1, i, cfp );
+ if (fread( cf_index, 1, i, cfp ) < (size_t)i)
+ tsl_error( TRUE, "reading initialised buffer for index");
/* Convert from Short_Univ_Int to short int */
sup = (Short_Univ_Int *) cf_index;
for (i=0; i<=univ2int(cfh.word_cnt); i++) {