7fa0199
From 176a7b4778fbacbbb0824cf8c612656cd0985499 Mon Sep 17 00:00:00 2001
7fa0199
From: Kalev Lember <klember@redhat.com>
7fa0199
Date: Tue, 7 Nov 2017 16:10:45 +0100
7fa0199
Subject: [PATCH] fetcher/curl: Fix invalid memory access in finalize()
7fa0199
7fa0199
Reorder cleanup functions so that curl_multi_cleanup() runs before
7fa0199
self->sockets is destroyed. This avoids an assert and invalid memory
7fa0199
access in sock_cb where self->sockets is dereferenced during
7fa0199
curl_multi_cleanup().
7fa0199
7fa0199
Closes: https://github.com/ostreedev/ostree/issues/1331
7fa0199
7fa0199
Closes: #1332
7fa0199
Approved by: cgwalters
7fa0199
---
7fa0199
 src/libostree/ostree-fetcher-curl.c | 2 +-
7fa0199
 1 file changed, 1 insertion(+), 1 deletion(-)
7fa0199
7fa0199
diff --git a/src/libostree/ostree-fetcher-curl.c b/src/libostree/ostree-fetcher-curl.c
7fa0199
index 1f64188258ed..8a23b16361ef 100644
7fa0199
--- a/src/libostree/ostree-fetcher-curl.c
7fa0199
+++ b/src/libostree/ostree-fetcher-curl.c
7fa0199
@@ -167,6 +167,7 @@ _ostree_fetcher_finalize (GObject *object)
7fa0199
 {
7fa0199
   OstreeFetcher *self = OSTREE_FETCHER (object);
7fa0199
 
7fa0199
+  curl_multi_cleanup (self->multi);
7fa0199
   g_free (self->remote_name);
7fa0199
   g_free (self->cookie_jar_path);
7fa0199
   g_free (self->proxy);
7fa0199
@@ -177,7 +178,6 @@ _ostree_fetcher_finalize (GObject *object)
7fa0199
   g_clear_pointer (&self->timer_event, (GDestroyNotify)destroy_and_unref_source);
7fa0199
   if (self->mainctx)
7fa0199
     g_main_context_unref (self->mainctx);
7fa0199
-  curl_multi_cleanup (self->multi);
7fa0199
 
7fa0199
   G_OBJECT_CLASS (_ostree_fetcher_parent_class)->finalize (object);
7fa0199
 }
7fa0199
-- 
7fa0199
2.14.2
7fa0199