]> pd.if.org Git - zpackage/commitdiff
fix possible memory leak in uncompress
authorNathan Wagner <nw@hydaspes.if.org>
Mon, 26 Nov 2018 05:58:42 +0000 (05:58 +0000)
committerNathan Wagner <nw@hydaspes.if.org>
Mon, 26 Nov 2018 05:58:42 +0000 (05:58 +0000)
lib/uncompress.c
zpm-note.c
zpm-syncfs.c

index cb8fed2b49b4d7a3d28e025f2e2a0f1b48bf1957..bbc1adbadfcfb3087fbbb67f0f608b8b7257dd61 100644 (file)
@@ -78,9 +78,11 @@ ssize_t uncompresslzma(void *buf, size_t bufsize, int out) {
                                // that there's no trailing garbage.
                                assert(strm->avail_in == 0);
                                //assert(action == LZMA_FINISH);
+                               lzma_end(strm);
                                return bytes;
                        }
 
+                       lzma_end(strm);
                        const char *msg;
                        switch (ret) {
                                case LZMA_MEM_ERROR:
index 927f30a45b8443ed6c93f92a25ae2061fdef35c7..33e7fa2a923b03de0779fefac186fa14798ca8d6 100644 (file)
@@ -106,5 +106,8 @@ int main(int ac, char **av){
        }
        fail = pkg.error;
        zpm_close(&pkg);
+       if (n.id) {
+               zpm_note_free(&n);
+       }
        return fail ? EXIT_FAILURE : EXIT_SUCCESS;
 }
index 0b88928d456ae875bd940a8d1fdabdf65c0f30ec..59a88256f66c0cfb963750b8119a856876ddd668 100644 (file)
@@ -871,6 +871,12 @@ static int install_files(void *f, int ncols, char **vals, char **cols) {
                return conf->errabort;
        }
 
+#if 0
+       int64_t used, high;
+       used = sqlite3_memory_used()/1024/1024;
+       high = sqlite3_memory_highwater(0)/1024/1024;
+       fprintf(stderr, "memory = %ld MB / %ld MB\n", used, high);
+#endif
        if (conf->verbose && !conf->dryrun) {
                fprintf(stderr, "%s '%c' %s\n", nitem.opstr, nitem.ftype,
                                nitem.dest);