From 339988d64465820bfce614d4939cdf6a03cd3c51 Mon Sep 17 00:00:00 2001 From: Nathan Wagner Date: Mon, 26 Nov 2018 05:20:00 +0000 Subject: [PATCH] fix bugs reported by static analyzer --- lib/integ.c | 4 ++++ lib/zpm.c | 2 ++ zpm-packagehash.c | 4 +--- zpm-quote.c | 1 + zpm-search.c | 9 +++------ 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/lib/integ.c b/lib/integ.c index 81667ea..57e7d87 100644 --- a/lib/integ.c +++ b/lib/integ.c @@ -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); } diff --git a/lib/zpm.c b/lib/zpm.c index 359c095..9b208cc 100644 --- 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; } diff --git a/zpm-packagehash.c b/zpm-packagehash.c index 6ca53af..6d5b912 100644 --- a/zpm-packagehash.c +++ b/zpm-packagehash.c @@ -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; diff --git a/zpm-quote.c b/zpm-quote.c index 97e4fe6..1aea24b 100644 --- a/zpm-quote.c +++ b/zpm-quote.c @@ -88,6 +88,7 @@ int main(int ac, char **av) { for (i=argn;i