]> pd.if.org Git - zpackage/commitdiff
fix bugs reported by static analyzer
authorNathan Wagner <nw@hydaspes.if.org>
Mon, 26 Nov 2018 05:20:00 +0000 (05:20 +0000)
committerNathan Wagner <nw@hydaspes.if.org>
Mon, 26 Nov 2018 05:20:00 +0000 (05:20 +0000)
lib/integ.c
lib/zpm.c
zpm-packagehash.c
zpm-quote.c
zpm-search.c

index 81667eae77cee6ebd721fabd5d93b1d555a6217a..57e7d87936bfd29417587248c9acb01f674ef352 100644 (file)
@@ -127,6 +127,10 @@ static void hash_query(struct zpm *zpm, const char *zSql, struct sha256_state *h
                                        hash_byte(h, 'B');
                                        hash_int(h, bytes);
                                        break;
+                               default:
+                                       hash_byte(h, 'U');
+                                       continue;
+                                       break;
                        }
                        sha256_process(h, data, bytes);
                }
index 359c0953e6608d091bc12f2a950ed34677db3ca1..9b208cc59a237dbabc28319cb7f56ac411bef8ec 100644 (file)
--- a/lib/zpm.c
+++ b/lib/zpm.c
@@ -398,6 +398,7 @@ int zpm_extract(struct zpm *pkg, char *hash, char *path, mode_t mode) {
                                        tmpfile, strerror(errno));
                        sqlite3_finalize(ifile);
                        sqlite3_close(db);
+                       free(tmpfile);
                        return 0;
                }
        } else {
@@ -432,6 +433,7 @@ int zpm_extract(struct zpm *pkg, char *hash, char *path, mode_t mode) {
                }
        }
 
+       free(tmpfile);
        return rc;
 }
 
index 6ca53af3c57274fda0b22c2d8ee272ad70387bc4..6d5b9128fabb5e4a007305f10637111af24dd649 100644 (file)
@@ -80,12 +80,10 @@ int main(int ac, char **av){
                }
 
                zpm_close(&pkg);
-               if (current) {
-                       free(current);
-               }
                if (display && !quiet) {
                        printf("%s\n", display);
                }
+               free(current);
        }
 
        return checkfail ? EXIT_FAILURE : 0;
index 97e4fe641420cdca4859d2e2984ff851a308ebef..1aea24b4dbb0811a769b0e37f9c0b1ea005459be 100644 (file)
@@ -88,6 +88,7 @@ int main(int ac, char **av) {
        for (i=argn;i<ac;i++) {
                quoted = quote(av[i], ch, repl, addquotes);
                printf("%s\n", quoted);
+               free(quoted);
        }
        return 0;
 }
index 290c0834c63dc76212beaeea680faf799d02f5ad..b431152e690fe8ec451ed488290ad7a93cd2afe0 100644 (file)
@@ -134,7 +134,6 @@ int find_globs(struct search_ctl *opt) {
                        default:
                                break;
                }
-               globopts = GLOB_APPEND;
                free(globstr);
        }
 
@@ -191,7 +190,7 @@ int find_lib(char *soname, struct search_ctl *opt, struct pkgloc *pkg) {
 struct pkgloc *find_package(char *pkgstr, struct search_ctl *opt) {
        char *latest = 0;
        char *installed = 0, *found = 0;
-       char *pkgfile;
+       char *pkgfile = 0;
        struct pkgloc *pkg = 0;
        int rv;
        unsigned int i;
@@ -345,12 +344,10 @@ void checklibs(struct search_ctl *opts,
                                }
                                /* shouldn't be in there already */
                                jsw_hinsert(forlibs, pkginfo.id, pkginfo.file);
-                       } 
-                       /* otherwise found == 2, so just continue */
-                       if (found) {
                                free(pkginfo.file);
                                free(pkginfo.id);
-                       }
+                       } 
+                       /* otherwise found == 2, so just continue */
                }
        }
        free(pkgid);