From: Victor Wagner Date: Tue, 26 Apr 2016 07:01:20 +0000 (+0300) Subject: Make clang static analyzer 3.5 happy X-Git-Tag: REL_0_95~13 X-Git-Url: http://wagner.pp.ru/gitweb/?a=commitdiff_plain;h=7de410970cd2916482178d730b64aef013b0567a;p=oss%2Fcatdoc.git Make clang static analyzer 3.5 happy --- diff --git a/src/charsets.c b/src/charsets.c index 4ee0f4c..a81ceeb 100644 --- a/src/charsets.c +++ b/src/charsets.c @@ -46,13 +46,14 @@ CHARSET make_reverse_map(short int *charset) { int i,j,k,l; short int *p; if (! charset) { + free(newmap); return NULL; } for (i=0;i<256;i++) { k= charset[i]; j= (unsigned)k>>8; if (!newmap[j]) { - newmap[j] = malloc(sizeof(short int *)*256); + newmap[j] = (short int *)malloc(sizeof(short int)*256); if (!newmap[j]) { fprintf(stderr,"Insufficient memory for charset\n"); exit(1); @@ -72,7 +73,7 @@ CHARSET make_reverse_map(short int *charset) { short int * read_charset(const char *filename) { char *path; FILE *f; - short int *new=calloc(sizeof(short int),256); + short int *new; int c; long int uc; path= find_file(stradd(filename,CHARSET_EXT),charset_path); @@ -89,6 +90,7 @@ short int * read_charset(const char *filename) { if (input_buffer) setvbuf(f,input_buffer,_IOFBF,FILE_BUFFER); /* defaults */ + new = calloc(sizeof(short int),256); for (c=0;c<32;c++) { new[c]=c; } diff --git a/src/fileutil.c b/src/fileutil.c index ce616c2..86139ec 100644 --- a/src/fileutil.c +++ b/src/fileutil.c @@ -180,14 +180,16 @@ void list_charsets(void) { char *q; char path_buf[PATH_BUF_SIZE]; char dir_sep[2]={DIR_SEP,0}; + char **ptr; #ifdef __MSDOS__ struct ffblk ffblock; int res,col; #else glob_t glob_buf; int count,glob_flags=GLOB_ERR; + + memset(&glob_buf,0,sizeof(glob_t)); #endif - char **ptr; for (p=charset_path;p;p=(q?(q+1):NULL)) { q=strchr(p,LIST_SEP); if (q) { diff --git a/src/ole.c b/src/ole.c index 5267dfa..d1c731d 100644 --- a/src/ole.c +++ b/src/ole.c @@ -328,6 +328,7 @@ FILE *ole_readdir(FILE *f) { (e->startBlock <= fileLength/(e->isBigBlock ? sectorSize : shortSectorSize))) { if((e->blocks=malloc(chainMaxLen*sizeof(long int))) == NULL ) { + free(e); return NULL; } while(1) { diff --git a/src/sheet.c b/src/sheet.c index 6d798c8..ec1f0c3 100644 --- a/src/sheet.c +++ b/src/sheet.c @@ -34,7 +34,9 @@ unsigned char **allocate (int row,int col) { } if (col>=rowptr[row].end) { newcol=(col/16+1)*16; - rowptr[row].cells=realloc(rowptr[row].cells,newcol*sizeof(char *)); + rowptr[row].cells= + (unsigned char**)realloc(rowptr[row].cells, + newcol*sizeof(unsigned char *)); if (rowptr[row].cells == NULL) { perror("allocating row"); exit(1); diff --git a/src/xlsparse.c b/src/xlsparse.c index 372eb08..5dd9b38 100644 --- a/src/xlsparse.c +++ b/src/xlsparse.c @@ -49,11 +49,13 @@ void do_table(FILE *input,char *filename) { if (reclen==8 || reclen==16) { if (biff_version == 0x0809 ) { itemsread=catdoc_read(rec,4,1,input); + if (itemsread == 0) + break; build_year=getshort(rec+2,0); build_rel=getshort(rec,0); (void) build_rel; if(build_year > 5 ) { - itemsread=catdoc_read(rec,8,1,input); + catdoc_read(rec,8,1,input); biff_version=8; offset=12; } @@ -86,19 +88,20 @@ void do_table(FILE *input,char *filename) { } while(itemsread){ unsigned char buffer[2]; - rectype = 0; + itemsread = catdoc_read(buffer, 2, 1, input); if (catdoc_eof(input)) { process_item(MSEOF,0,NULL); return; } - rectype=getshort(buffer,0); if(itemsread == 0) break; - reclen=0; + rectype=getshort(buffer,0); itemsread = catdoc_read(buffer, 2, 1, input); + if(itemsread == 0) + break; reclen=getshort(buffer,0); if (reclen && reclen 0){ itemsread = catdoc_read(rec, 1, reclen, input); @@ -440,7 +443,6 @@ unsigned char *copy_unicode_string (unsigned char **src) { count=**src; flags = *(*src+offset); offset --; - flags = *(*src+1+offset); if (! ( flags == 0 || flags == 1 || flags == 8 || flags == 9 || flags == 4 || flags == 5 || flags == 0x0c || flags == 0x0d ) ) { /* fprintf(stderr,"Strange flags = %d, returning NULL\n", flags); */ @@ -520,7 +522,6 @@ unsigned char *copy_unicode_string (unsigned char **src) { } d=dest+l; strcpy((char *)d,(char *)c); - d+=dl; l+=dl; } } @@ -761,7 +762,7 @@ void parse_sst(unsigned char *sstbuf,int bufsize) { unsigned char **parsedString;/*pointer into parsed array*/ sstsize = getlong(sstbuf+4,0); - sst=malloc(sstsize*sizeof(char *)); + sst=(unsigned char **)malloc(sstsize*sizeof(unsigned char *)); if (sst == NULL) { perror("SST allocation error");