summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Garnacho <carlosg@gnome.org>2023-05-04 12:13:29 +0200
committerCarlos Garnacho <carlosg@gnome.org>2023-05-04 12:13:29 +0200
commit18217f0545e4c20a9d41424d62a6fe6be53788dd (patch)
tree14e50ccb18c040823fffb6b7b24ee6c5d25faab1
parent16ab9f02340cb2ded6dfd503eb476744b93fa13f (diff)
downloadtracker-18217f0545e4c20a9d41424d62a6fe6be53788dd.tar.gz
remote: Fix possible double free
In case of error reading from the input stream, we would propagate the error through the GTask and break, falling through paths that also try to return and free the task. Handle the task entirely at the end of the function, based on the return value. We still need to close the input stream and soup message in any case. CID: #1517496
-rw-r--r--src/libtracker-sparql/remote/tracker-http-module.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/src/libtracker-sparql/remote/tracker-http-module.c b/src/libtracker-sparql/remote/tracker-http-module.c
index ed87cd1b7..a74ec3d37 100644
--- a/src/libtracker-sparql/remote/tracker-http-module.c
+++ b/src/libtracker-sparql/remote/tracker-http-module.c
@@ -240,11 +240,8 @@ handle_write_in_thread (GTask *task,
count = g_input_stream_read (request->istream,
buffer, sizeof (buffer),
cancellable, &error);
- if (count < 0) {
- g_task_return_error (task, error);
- g_object_unref (task);
+ if (count < 0)
break;
- }
soup_message_body_append (message_body,
SOUP_MEMORY_COPY,
@@ -257,7 +254,12 @@ handle_write_in_thread (GTask *task,
g_input_stream_close (request->istream, cancellable, NULL);
soup_message_body_complete (message_body);
- g_task_return_boolean (task, TRUE);
+
+ if (error)
+ g_task_return_error (task, error);
+ else
+ g_task_return_boolean (task, TRUE);
+
g_object_unref (task);
}