[gnome-software/gnome-3-14] 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-14] screenshot image: Don't crash if we get a libsoup callback after dispose
- Date: Thu, 4 Jun 2015 22:45:52 +0000 (UTC)
commit 0515a7001f673bfc17beefb1781e76f1d0eb7624
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 0d6d60d..6c8140b 100644
--- a/src/gs-screenshot-image.c
+++ b/src/gs-screenshot-image.c
@@ -206,15 +206,16 @@ gs_screenshot_image_complete_cb (SoupSession *session,
SoupMessage *msg,
gpointer user_data)
{
- AsImage *im = NULL;
- GsScreenshotImagePrivate *priv;
GsScreenshotImage *ssimg = GS_SCREENSHOT_IMAGE (user_data);
+ GsScreenshotImagePrivate *priv = gs_screenshot_image_get_instance_private (ssimg);
+ AsImage *im = NULL;
GError *error = NULL;
GdkPixbuf *pixbuf = NULL;
GInputStream *stream = NULL;
gboolean ret;
- 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)
goto out;
if (msg->status_code != SOUP_STATUS_OK) {
@@ -225,8 +226,6 @@ gs_screenshot_image_complete_cb (SoupSession *session,
goto out;
}
- 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]