[gnome-software/gnome-3-16] screenshot image: Don't crash if we get a libsoup callback after dispose
- From: Kalev Lember <klember src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software/gnome-3-16] screenshot image: Don't crash if we get a libsoup callback after dispose
- Date: Thu, 4 Jun 2015 22:40:32 +0000 (UTC)
commit 645129074ddd589cbb2afd6b939c2eae6bb3ed35
Author: Kalev Lember <kalevlember gmail com>
Date: Thu Jun 4 22:24:09 2015 +0200
screenshot image: Don't crash if we get a libsoup callback after dispose
If dispose has already run and we get a callback from libsoup, just
return immediately, avoiding crashing down below due to cleared priv
data. Since the priv->session pointer is cleared in destroy(), we can
check if it's NULL to detect if dispose has already run.
This should fully fix the crash reported in
https://bugzilla.redhat.com/show_bug.cgi?id=1137027
src/gs-screenshot-image.c | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)
---
diff --git a/src/gs-screenshot-image.c b/src/gs-screenshot-image.c
index 59479ae..7234fe6 100644
--- a/src/gs-screenshot-image.c
+++ b/src/gs-screenshot-image.c
@@ -230,15 +230,16 @@ gs_screenshot_image_complete_cb (SoupSession *session,
SoupMessage *msg,
gpointer user_data)
{
- GsScreenshotImagePrivate *priv;
+ _cleanup_object_unref_ GsScreenshotImage *ssimg = GS_SCREENSHOT_IMAGE (user_data);
+ GsScreenshotImagePrivate *priv = gs_screenshot_image_get_instance_private (ssimg);
gboolean ret;
_cleanup_error_free_ GError *error = NULL;
_cleanup_object_unref_ AsImage *im = NULL;
_cleanup_object_unref_ GdkPixbuf *pixbuf = NULL;
_cleanup_object_unref_ GInputStream *stream = NULL;
- _cleanup_object_unref_ GsScreenshotImage *ssimg = GS_SCREENSHOT_IMAGE (user_data);
- if (msg->status_code == SOUP_STATUS_CANCELLED)
+ /* return immediately if the message was cancelled or if we're in destruction */
+ if (msg->status_code == SOUP_STATUS_CANCELLED || priv->session == NULL)
return;
if (msg->status_code != SOUP_STATUS_OK) {
@@ -249,8 +250,6 @@ gs_screenshot_image_complete_cb (SoupSession *session,
return;
}
- priv = gs_screenshot_image_get_instance_private (ssimg);
-
/* create a buffer with the data */
stream = g_memory_input_stream_new_from_data (msg->response_body->data,
msg->response_body->length,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]