From: Victor Wagner Date: Wed, 27 Apr 2016 12:21:10 +0000 (+0300) Subject: Fix resource leaks found by cppcheck X-Git-Tag: REL_0_95~1^2~3 X-Git-Url: http://wagner.pp.ru/gitweb/?a=commitdiff_plain;h=73b1dd7326585b7c18ce6e24320656d0d6f843cc;p=oss%2Fcatdoc.git Fix resource leaks found by cppcheck --- diff --git a/src/charsets.c b/src/charsets.c index 49875e3..0511876 100644 --- a/src/charsets.c +++ b/src/charsets.c @@ -99,6 +99,7 @@ short int * read_charset(const char *filename) { if (c<0||c>255||uc<0||(uc>0xFEFE&& uc!=0xFFFE)) { fprintf(stderr,"Invalid charset file %s\n",path); fclose(f); + free(new); return NULL; } new[c]=uc; diff --git a/src/fileutil.c b/src/fileutil.c index 86139ec..5ae039f 100644 --- a/src/fileutil.c +++ b/src/fileutil.c @@ -111,6 +111,8 @@ int check_charset(char **filename,const char *charset) { *filename=strdup(charset); free(tmppath); return 1; + } else { + free(tmppath); } } return 0; diff --git a/src/ole.c b/src/ole.c index e131a0d..3aa8805 100644 --- a/src/ole.c +++ b/src/ole.c @@ -74,6 +74,7 @@ FILE* ole_init(FILE *f, void *buffer, size_t bufSize) { ret=fwrite(buffer, 1, bufSize, newfile); if(ret != bufSize) { perror("Can't write to tmp file"); + fclose(newfile); return NULL; } }