[gjs] maint: Fix memory leaks
- From: Philip Chimento <pchimento src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gjs] maint: Fix memory leaks
- Date: Tue, 28 Feb 2017 00:00:19 +0000 (UTC)
commit 165b5b94740222adc862f16b2d23f9e83f06b8b4
Author: Philip Chimento <philip chimento gmail com>
Date: Sun Feb 26 16:54:21 2017 -0800
maint: Fix memory leaks
Some memory leaks uncovered by Valgrind.
https://bugzilla.gnome.org/show_bug.cgi?id=779293
gjs/context.cpp | 2 ++
gjs/coverage.cpp | 7 +++----
test/gjs-test-call-args.cpp | 2 ++
3 files changed, 7 insertions(+), 4 deletions(-)
---
diff --git a/gjs/context.cpp b/gjs/context.cpp
index dc1ba70..08292fb 100644
--- a/gjs/context.cpp
+++ b/gjs/context.cpp
@@ -345,6 +345,7 @@ gjs_context_class_init(GjsContextClass *klass)
g_object_class_install_property(object_class,
PROP_SEARCH_PATH,
pspec);
+ g_param_spec_unref(pspec);
pspec = g_param_spec_string("program-name",
"Program Name",
@@ -355,6 +356,7 @@ gjs_context_class_init(GjsContextClass *klass)
g_object_class_install_property(object_class,
PROP_PROGRAM_NAME,
pspec);
+ g_param_spec_unref(pspec);
/* For GjsPrivate */
{
diff --git a/gjs/coverage.cpp b/gjs/coverage.cpp
index d8a6ae7..09a6fc3 100644
--- a/gjs/coverage.cpp
+++ b/gjs/coverage.cpp
@@ -292,7 +292,7 @@ copy_source_file_to_coverage_output(GFile *source_file,
/* We need to recursively make the directory we
* want to copy to, as g_file_copy doesn't do that */
- GFile *destination_dir = g_file_get_parent(destination_file);
+ GjsAutoUnref<GFile> destination_dir = g_file_get_parent(destination_file);
if (!g_file_make_directory_with_parents(destination_dir, NULL, &error)) {
if (!g_error_matches(error, G_IO_ERROR, G_IO_ERROR_EXISTS))
goto fail;
@@ -1037,10 +1037,9 @@ gjs_deserialize_cache_to_object_for_compartment(JSContext *context,
global_object));
gsize len = 0;
- gpointer string = g_bytes_unref_to_data(g_bytes_ref(cache_data),
- &len);
+ auto string = static_cast<const char *>(g_bytes_get_data(cache_data, &len));
- return JS_NewStringCopyN(context, (const char *) string, len);
+ return JS_NewStringCopyN(context, string, len);
}
JSString *
diff --git a/test/gjs-test-call-args.cpp b/test/gjs-test-call-args.cpp
index 90414a3..9eea273 100644
--- a/test/gjs-test-call-args.cpp
+++ b/test/gjs-test-call-args.cpp
@@ -108,6 +108,8 @@ JSNATIVE_TEST_FUNC_BEGIN(one_of_each_type)
g_assert_cmpint(int64val, ==, 1);
g_assert_cmpfloat(dblval, ==, 1.0);
g_assert_nonnull(objval);
+ g_free(strval);
+ g_free(fileval);
JSNATIVE_TEST_FUNC_END
JSNATIVE_TEST_FUNC_BEGIN(optional_args_all)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]