From 73b1dd7326585b7c18ce6e24320656d0d6f843cc Mon Sep 17 00:00:00 2001 From: Victor Wagner Date: Wed, 27 Apr 2016 15:21:10 +0300 Subject: [PATCH] Fix resource leaks found by cppcheck --- src/charsets.c | 1 + src/fileutil.c | 2 ++ src/ole.c | 1 + 3 files changed, 4 insertions(+) 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; } } -- 2.39.5