[eog/bugfix/crash-without-mimetype] EogImage: Do not crash if content type or filesize cannot be detected
- From: Felix Riemann <friemann src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [eog/bugfix/crash-without-mimetype] EogImage: Do not crash if content type or filesize cannot be detected
- Date: Thu, 12 Aug 2021 18:56:23 +0000 (UTC)
commit 449f11ab454a243c0f450818c8e700bf9c717cda
Author: Felix Riemann <friemann gnome org>
Date: Thu Aug 12 20:52:00 2021 +0200
EogImage: Do not crash if content type or filesize cannot be detected
It it possible that GIO may be unable to determine a file's content type
or filesize (e.g. due to file transport limitations). This avoids a
crash in this case and instead tries to guess the content type. Filesize
will stay at 0 though.
Fixes #204.
src/eog-image.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/src/eog-image.c b/src/eog-image.c
index 6075dad2..8cec597c 100644
--- a/src/eog-image.c
+++ b/src/eog-image.c
@@ -908,8 +908,8 @@ eog_image_new_pixbuf_loader (EogImage *img,
priv->svg = NULL;
}
- if (!strcmp (mime_type, "image/svg+xml")
- || !strcmp (mime_type, "image/svg+xml-compressed")
+ if (!g_strcmp0 (mime_type, "image/svg+xml")
+ || !g_strcmp0 (mime_type, "image/svg+xml-compressed")
) {
/* Keep the object for rendering */
priv->svg = rsvg_handle_new ();
@@ -924,11 +924,12 @@ eog_image_new_pixbuf_loader (EogImage *img,
#endif
if (!(*is_svg)) {
- loader = gdk_pixbuf_loader_new_with_mime_type (mime_type, error);
+ if (G_LIKELY (mime_type))
+ loader = gdk_pixbuf_loader_new_with_mime_type (mime_type,
+ error);
- if (error && *error) {
- g_error_free (*error);
- *error = NULL;
+ if (loader == NULL) {
+ g_clear_error (error);
loader = gdk_pixbuf_loader_new ();
}
@@ -1123,7 +1124,7 @@ eog_image_real_load (EogImage *img,
if (eog_job_is_cancelled (job)) {
eog_image_cancel_load (img);
continue;
- } else {
+ } else if (priv->bytes > 0.0) {
float progress = (float) bytes_read_total / (float) priv->bytes;
eog_job_set_progress (job, progress);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]