Fix resource leaks found by cppcheck
authorVictor Wagner <vitus@wagner.pp.ru>
Wed, 27 Apr 2016 12:21:10 +0000 (15:21 +0300)
committerVictor Wagner <vitus@wagner.pp.ru>
Wed, 27 Apr 2016 12:21:10 +0000 (15:21 +0300)
src/charsets.c
src/fileutil.c
src/ole.c

index 49875e3b4f27f4251d4778fefed382ed135040be..05118767815072f301bee1cd0f202d3249d55079 100644 (file)
@@ -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;
index 86139ecdb833e332679d5ec03078b7198319713c..5ae039f5cd603eb9f57b5338266af4c051b227d8 100644 (file)
@@ -111,6 +111,8 @@ int check_charset(char **filename,const char *charset) {
                        *filename=strdup(charset);
                        free(tmppath);
                        return 1;
+               } else {
+                       free(tmppath);
                }
        }
        return 0;
index e131a0dac2140921121edfeda7c65dc14fa3ffca..3aa880567f0104923024fc4273eeb7212e9c7331 100644 (file)
--- 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;
                                }
                        }