main: do cleanup when checking required version

master
Dylan Baker 2022-08-03 16:37:04 -07:00
parent a391f9b650
commit 4493a322f6
1 changed files with 18 additions and 6 deletions

View File

@ -1183,17 +1183,21 @@ main(int argc, char *argv[])
pkgconf_error(&pkg_client, "Package '%s' was not found\n", pkgiter->package); pkgconf_error(&pkg_client, "Package '%s' was not found\n", pkgiter->package);
ret = EXIT_FAILURE; ret = EXIT_FAILURE;
goto out; goto cleanup;
} }
if (pkgconf_compare_version(pkg->version, required_module_version) >= 0) if (pkgconf_compare_version(pkg->version, required_module_version) >= 0)
{ {
ret = EXIT_SUCCESS; ret = EXIT_SUCCESS;
goto out; goto cleanup;
} }
} }
ret = EXIT_FAILURE; ret = EXIT_FAILURE;
cleanup:
if (pkg)
pkgconf_pkg_unref(&pkg_client, pkg);
pkgconf_dependency_free(&deplist);
goto out; goto out;
} }
else if (required_exact_module_version != NULL) else if (required_exact_module_version != NULL)
@ -1219,17 +1223,21 @@ main(int argc, char *argv[])
pkgconf_error(&pkg_client, "Package '%s' was not found\n", pkgiter->package); pkgconf_error(&pkg_client, "Package '%s' was not found\n", pkgiter->package);
ret = EXIT_FAILURE; ret = EXIT_FAILURE;
goto out; goto cleanup2;
} }
if (pkgconf_compare_version(pkg->version, required_exact_module_version) == 0) if (pkgconf_compare_version(pkg->version, required_exact_module_version) == 0)
{ {
ret = EXIT_SUCCESS; ret = EXIT_SUCCESS;
goto out; goto cleanup2;
} }
} }
ret = EXIT_FAILURE; ret = EXIT_FAILURE;
cleanup2:
if (pkg)
pkgconf_pkg_unref(&pkg_client, pkg);
pkgconf_dependency_free(&deplist);
goto out; goto out;
} }
else if (required_max_module_version != NULL) else if (required_max_module_version != NULL)
@ -1255,17 +1263,21 @@ main(int argc, char *argv[])
pkgconf_error(&pkg_client, "Package '%s' was not found\n", pkgiter->package); pkgconf_error(&pkg_client, "Package '%s' was not found\n", pkgiter->package);
ret = EXIT_FAILURE; ret = EXIT_FAILURE;
goto out; goto cleanup3;
} }
if (pkgconf_compare_version(pkg->version, required_max_module_version) <= 0) if (pkgconf_compare_version(pkg->version, required_max_module_version) <= 0)
{ {
ret = EXIT_SUCCESS; ret = EXIT_SUCCESS;
goto out; goto cleanup3;
} }
} }
ret = EXIT_FAILURE; ret = EXIT_FAILURE;
cleanup3:
if (pkg)
pkgconf_pkg_unref(&pkg_client, pkg);
pkgconf_dependency_free(&deplist);
goto out; goto out;
} }