summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTimo Teräs <timo.teras@iki.fi>2012-02-17 10:02:44 +0200
committerTimo Teräs <timo.teras@iki.fi>2012-02-17 10:02:44 +0200
commita9d526836e1160b2233bf26a2d1dd6584dec5dd4 (patch)
treea5831890baf099d2978e660a66057f1cbfaa498f
parent15c920ab9060413c6f084a71da4995f8a319813b (diff)
downloadapk-tools-a9d526836e1160b2233bf26a2d1dd6584dec5dd4.tar.gz
apk-tools-a9d526836e1160b2233bf26a2d1dd6584dec5dd4.tar.bz2
apk-tools-a9d526836e1160b2233bf26a2d1dd6584dec5dd4.tar.xz
apk-tools-a9d526836e1160b2233bf26a2d1dd6584dec5dd4.zip
apk: fix some unharmful leaks reported by valgrind
-rw-r--r--src/apk.c26
-rw-r--r--src/database.c1
-rw-r--r--src/solver.c1
3 files changed, 19 insertions, 9 deletions
diff --git a/src/apk.c b/src/apk.c
index ccab27e..4fce15b 100644
--- a/src/apk.c
+++ b/src/apk.c
@@ -316,8 +316,8 @@ int main(int argc, char **argv)
case 0:
break;
case 'h':
- return usage(applet);
- break;
+ r = usage(applet);
+ goto err;
case 'p':
dbopts.root = optarg;
break;
@@ -339,7 +339,8 @@ int main(int argc, char **argv)
apk_verbosity++;
break;
case 'V':
- return version();
+ r = version();
+ goto err;
case 'f':
apk_flags |= APK_FORCE;
break;
@@ -383,14 +384,18 @@ int main(int argc, char **argv)
if (applet == NULL || applet->parse == NULL ||
applet->parse(ctx, &dbopts, r,
optindex - ARRAY_SIZE(generic_options),
- optarg) != 0)
- return usage(applet);
+ optarg) != 0) {
+ r = usage(applet);
+ goto err;
+ }
break;
}
}
- if (applet == NULL)
- return usage(NULL);
+ if (applet == NULL) {
+ r = usage(NULL);
+ goto err;
+ }
argc -= optind;
argv += optind;
@@ -403,13 +408,16 @@ int main(int argc, char **argv)
if (r != 0) {
apk_error("Failed to open apk database: %s",
apk_error_str(r));
- return r;
+ goto err;
}
r = applet->main(ctx, &db, argc, argv);
apk_db_close(&db);
if (r == -EINVAL)
- return usage(applet);
+ r = usage(applet);
+err:
+ if (ctx)
+ free(ctx);
return r;
}
diff --git a/src/database.c b/src/database.c
index 11f705d..e6945c3 100644
--- a/src/database.c
+++ b/src/database.c
@@ -1508,6 +1508,7 @@ void apk_db_close(struct apk_database *db)
for (i = 0; i < db->num_repos; i++) {
free(db->repos[i].url);
+ free(db->repos[i].description.ptr);
}
for (i = 0; i < db->protected_paths->num; i++)
free(db->protected_paths->item[i]);
diff --git a/src/solver.c b/src/solver.c
index 7d5a5b3..0283791 100644
--- a/src/solver.c
+++ b/src/solver.c
@@ -1630,6 +1630,7 @@ int apk_solver_commit(struct apk_database *db,
apk_solver_print_errors(db, solution, world, r);
}
apk_solution_array_free(&solution);
+ apk_change_array_free(&changeset.changes);
return r;
}