|
|
4c949f |
From ba648511089973f86b5345abfab9fd2fdbdd9ca6 Mon Sep 17 00:00:00 2001
|
|
|
4c949f |
From: =?UTF-8?q?Fabiano=20Fid=C3=AAncio?= <fidencio@redhat.com>
|
|
|
4c949f |
Date: Tue, 21 May 2019 13:29:18 +0200
|
|
|
4c949f |
Subject: [PATCH] tree: Avoid use of memory after it's freed
|
|
|
4c949f |
MIME-Version: 1.0
|
|
|
4c949f |
Content-Type: text/plain; charset=UTF-8
|
|
|
4c949f |
Content-Transfer-Encoding: 8bit
|
|
|
4c949f |
|
|
|
4c949f |
We've been passing data->location as the @url argument of
|
|
|
4c949f |
osinfo_tree_create_from_location_async_helper(), freeing it and trying
|
|
|
4c949f |
to g_strdup() it as the new content of data->location.
|
|
|
4c949f |
|
|
|
4c949f |
In order to avoid doing so, let's set the data->location only once, in
|
|
|
4c949f |
the first caller of osinfo_tree_create_from_location_async_helper(), as
|
|
|
4c949f |
its content is always going to be the same doesn't matter the treeinfo
|
|
|
4c949f |
format to be used with.
|
|
|
4c949f |
|
|
|
4c949f |
Signed-off-by: Fabiano FidĂȘncio <fidencio@redhat.com>
|
|
|
4c949f |
Reviewed-by: Cole Robinson <crobinso@redhat.com>
|
|
|
4c949f |
(cherry picked from commit d7bc838a96acf5f058e13d2b49157b4ba396cd87)
|
|
|
4c949f |
---
|
|
|
4c949f |
osinfo/osinfo_tree.c | 5 ++---
|
|
|
4c949f |
1 file changed, 2 insertions(+), 3 deletions(-)
|
|
|
4c949f |
|
|
|
4c949f |
diff --git a/osinfo/osinfo_tree.c b/osinfo/osinfo_tree.c
|
|
|
4c949f |
index eaac54f..2e6a4ee 100644
|
|
|
4c949f |
--- a/osinfo/osinfo_tree.c
|
|
|
4c949f |
+++ b/osinfo/osinfo_tree.c
|
|
|
4c949f |
@@ -667,9 +667,6 @@ osinfo_tree_create_from_location_async_helper(const gchar *url,
|
|
|
4c949f |
g_clear_object(&data->file);
|
|
|
4c949f |
data->file = g_file_new_for_uri(location);
|
|
|
4c949f |
|
|
|
4c949f |
- g_free(data->location);
|
|
|
4c949f |
- data->location = g_strdup(url);
|
|
|
4c949f |
-
|
|
|
4c949f |
g_free(data->treeinfo);
|
|
|
4c949f |
data->treeinfo = g_strdup(treeinfo);
|
|
|
4c949f |
|
|
|
4c949f |
@@ -705,6 +702,8 @@ void osinfo_tree_create_from_location_async(const gchar *location,
|
|
|
4c949f |
user_data);
|
|
|
4c949f |
g_task_set_priority(data->res, priority);
|
|
|
4c949f |
|
|
|
4c949f |
+ data->location = g_strdup(location);
|
|
|
4c949f |
+
|
|
|
4c949f |
osinfo_tree_create_from_location_async_helper(location,
|
|
|
4c949f |
".treeinfo",
|
|
|
4c949f |
cancellable,
|
|
|
4c949f |
--
|
|
|
4c949f |
2.21.0
|
|
|
4c949f |
|