From d15baaaad2406482bda007fcb519ea78f3e40b34 Mon Sep 17 00:00:00 2001 From: Yevgen Muntyan <17531749+muntyan@users.noreply.github.com> Date: Tue, 25 Jan 2011 03:17:10 -0800 Subject: [PATCH] Fixed bunch of memory leaks --- moo/mooedit/mooeditfileinfo.c | 2 ++ moo/mooedit/mooeditor.c | 18 ++++++++++++------ moo/moolua/moolua-tests.cpp | 1 + 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/moo/mooedit/mooeditfileinfo.c b/moo/mooedit/mooeditfileinfo.c index 70db5f97..29f57f36 100644 --- a/moo/mooedit/mooeditfileinfo.c +++ b/moo/mooedit/mooeditfileinfo.c @@ -39,6 +39,8 @@ G_DEFINE_TYPE (MooReloadInfo, moo_reload_info, G_TYPE_OBJECT) * @encoding: (type const-utf8) (allow-none) (default NULL) * @line: (type index) (default -1) * @flags: (default 0) + * + * Returns: (transfer full) **/ MooOpenInfo * moo_open_info_new_file (GFile *file, diff --git a/moo/mooedit/mooeditor.c b/moo/mooedit/mooeditor.c index 30b98213..c917a114 100644 --- a/moo/mooedit/mooeditor.c +++ b/moo/mooedit/mooeditor.c @@ -1160,6 +1160,7 @@ moo_editor_load_file (MooEditor *editor, if (new_object) g_object_unref (doc); + g_free (filename); g_free (uri); return success ? doc : NULL; } @@ -2460,7 +2461,8 @@ moo_editor_reload (MooEditor *editor, guint i; GError *error_here = NULL; MooEditView *active_view; - MooEditViewArray *views; + MooEditViewArray *views = NULL; + gboolean ret = FALSE; moo_return_error_if_fail (MOO_IS_EDITOR (editor)); @@ -2470,7 +2472,7 @@ moo_editor_reload (MooEditor *editor, MOO_EDIT_RELOAD_ERROR, MOO_EDIT_RELOAD_ERROR_BUSY, "document is busy"); - return FALSE; + goto out; } if (moo_edit_is_untitled (doc)) @@ -2479,7 +2481,7 @@ moo_editor_reload (MooEditor *editor, MOO_EDIT_RELOAD_ERROR, MOO_EDIT_RELOAD_ERROR_UNTITLED, "document is untitled"); - return FALSE; + goto out; } if (!is_embedded (editor) && @@ -2491,7 +2493,7 @@ moo_editor_reload (MooEditor *editor, MOO_EDIT_RELOAD_ERROR, MOO_EDIT_RELOAD_ERROR_CANCELLED, "cancelled by user"); - return FALSE; + goto out; } views = moo_edit_get_views (doc); @@ -2531,7 +2533,7 @@ moo_editor_reload (MooEditor *editor, moo_text_view_undo (MOO_TEXT_VIEW (active_view)); g_object_set_data (G_OBJECT (doc), "moo-scroll-to", NULL); - return FALSE; + goto out; } for (i = 0; i < moo_edit_view_array_get_size (views); ++i) @@ -2546,7 +2548,11 @@ moo_editor_reload (MooEditor *editor, cursor_offset, TRUE, TRUE); } - return TRUE; + ret = TRUE; + +out: + moo_edit_view_array_free (views); + return ret; } diff --git a/moo/moolua/moolua-tests.cpp b/moo/moolua/moolua-tests.cpp index 0aa895e0..66761b40 100644 --- a/moo/moolua/moolua-tests.cpp +++ b/moo/moolua/moolua-tests.cpp @@ -137,5 +137,6 @@ moo_test_lua (MooTestOptions opts) continue; test_name = g_strndup (basename + strlen ("test"), strlen (basename) - strlen ("test") - strlen (".lua")); moo_test_suite_add_test (suite, test_name, basename, test_func, (char*) basename); + g_free (test_name); } }