summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Hughes <richard@hughsie.com>2017-06-22 16:20:51 +0100
committerRichard Hughes <richard@hughsie.com>2017-06-22 16:20:51 +0100
commit26d268b6bb005ba983bb8ab07b4b287ea66639f8 (patch)
tree24fc3d5783a6fd6ec8dd9a776266b75b970af69a
parentdf2531febeaa7bdfcd86ef2e0c37eca13efe46d4 (diff)
downloadappstream-glib-26d268b6bb005ba983bb8ab07b4b287ea66639f8.tar.gz
trivial: Fix up several small memory leaks
-rw-r--r--libappstream-glib/as-app-builder.c4
-rw-r--r--libappstream-glib/as-image.c12
-rw-r--r--libappstream-glib/as-self-test.c4
3 files changed, 11 insertions, 9 deletions
diff --git a/libappstream-glib/as-app-builder.c b/libappstream-glib/as-app-builder.c
index db8ac9f..b3765ea 100644
--- a/libappstream-glib/as-app-builder.c
+++ b/libappstream-glib/as-app-builder.c
@@ -505,7 +505,6 @@ as_app_builder_search_translations_pak (AsAppBuilderContext *ctx,
for (i = 0; i < ctx->translations->len; i++) {
const gchar *tmp;
g_autoptr(GDir) dir = NULL;
- g_autofree gchar *path = NULL;
AsTranslation *t = g_ptr_array_index (ctx->translations, i);
const gchar *libdirs[] = { "lib64", "lib", NULL };
@@ -513,6 +512,7 @@ as_app_builder_search_translations_pak (AsAppBuilderContext *ctx,
if (as_translation_get_id (t) == NULL)
continue;
for (guint j = 0; libdirs[j] != NULL; j++) {
+ g_autofree gchar *path = NULL;
path = g_build_filename (prefix,
libdirs[j],
as_translation_get_id (t),
@@ -576,12 +576,12 @@ as_app_builder_search_translations_xpi (AsAppBuilderContext *ctx,
GError **error)
{
const gchar *tmp;
- g_autofree gchar *path = NULL;
g_autoptr(GDir) dir = NULL;
const gchar *libdirs[] = { "lib64", "lib", NULL };
/* list files */
for (guint j = 0; libdirs[j] != NULL; j++) {
+ g_autofree gchar *path = NULL;
path = g_build_filename (prefix,
libdirs[j],
"firefox",
diff --git a/libappstream-glib/as-image.c b/libappstream-glib/as-image.c
index c101c61..55067e5 100644
--- a/libappstream-glib/as-image.c
+++ b/libappstream-glib/as-image.c
@@ -534,6 +534,7 @@ as_image_load_filename_full (AsImage *image,
/* only support non-deprecated types */
if (flags & AS_IMAGE_LOAD_FLAG_ONLY_SUPPORTED) {
GdkPixbufFormat *fmt;
+ g_autofree gchar *name = NULL;
fmt = gdk_pixbuf_get_file_info (filename, NULL, NULL);
if (fmt == NULL) {
g_set_error_literal (error,
@@ -542,15 +543,16 @@ as_image_load_filename_full (AsImage *image,
"image format was not recognized");
return FALSE;
}
- if (g_strcmp0 (gdk_pixbuf_format_get_name (fmt), "png") != 0 &&
- g_strcmp0 (gdk_pixbuf_format_get_name (fmt), "jpeg") != 0 &&
- g_strcmp0 (gdk_pixbuf_format_get_name (fmt), "xpm") != 0 &&
- g_strcmp0 (gdk_pixbuf_format_get_name (fmt), "svg") != 0) {
+ name = gdk_pixbuf_format_get_name (fmt);
+ if (g_strcmp0 (name, "png") != 0 &&
+ g_strcmp0 (name, "jpeg") != 0 &&
+ g_strcmp0 (name, "xpm") != 0 &&
+ g_strcmp0 (name, "svg") != 0) {
g_set_error (error,
AS_UTILS_ERROR,
AS_UTILS_ERROR_FAILED,
"image format %s is not supported",
- gdk_pixbuf_format_get_name (fmt));
+ name);
return FALSE;
}
}
diff --git a/libappstream-glib/as-self-test.c b/libappstream-glib/as-self-test.c
index 75171ec..3df66f6 100644
--- a/libappstream-glib/as-self-test.c
+++ b/libappstream-glib/as-self-test.c
@@ -2320,7 +2320,7 @@ as_test_store_validate_func (void)
static void
_as_app_add_format_kind (AsApp *app, AsFormatKind kind)
{
- AsFormat *format = as_format_new ();
+ g_autoptr(AsFormat) format = as_format_new ();
as_format_set_kind (format, kind);
as_app_add_format (app, format);
}
@@ -3760,13 +3760,13 @@ static void
as_test_store_unique_func (void)
{
AsApp *app;
- GPtrArray *apps;
g_autoptr(AsApp) app1 = NULL;
g_autoptr(AsApp) app2 = NULL;
g_autoptr(AsApp) app3 = NULL;
g_autoptr(AsBundle) bundle2 = NULL;
g_autoptr(AsBundle) bundle3 = NULL;
g_autoptr(AsStore) store = NULL;
+ g_autoptr(GPtrArray) apps = NULL;
/* create a store and add a single app */
store = as_store_new ();