Bug 4735 - adjust logic in image_viewer_load_image
Summary: adjust logic in image_viewer_load_image
Status: NEW
Alias: None
Product: Claws Mail
Classification: Unclassified
Component: Other (show other bugs)
Version: 4.3.0
Hardware: PC All
: P3 normal
Assignee: users
URL:
Depends on:
Blocks:
 
Reported: 2024-01-11 11:46 UTC by olaf
Modified: 2024-02-01 11:04 UTC (History)
0 users

See Also:


Attachments
gtk2-adjust-logic-in-image_viewer_load_image.patch (1.37 KB, patch)
2024-01-11 11:46 UTC, olaf
Details | Diff
master-adjust-logic-in-image_viewer_load_image.patch (1.43 KB, patch)
2024-01-11 11:47 UTC, olaf
Details | Diff

Description olaf 2024-01-11 11:46:52 UTC
Created attachment 2399 [details]
gtk2-adjust-logic-in-image_viewer_load_image.patch

The function gdk_pixbuf_animation_new_from_stream may return NULL.
Take the branch only if animation is valid.
  
  image_viewer.c: In function 'image_viewer_load_image':
  image_viewer.c:105:16: warning: suggest parentheses around '&&' within '||' [-Wparentheses]
    if (animation && gdk_pixbuf_animation_is_static_image(animation)

Fixes commit 05f600e5826ab4fd43e345b87bf1029c1fef48f7
Fixes commit e121fc4767e57fd6018997b75d636264049c9ce8
Fixes commit d006355369916eefff3d964d4606e183339418aa
Comment 1 olaf 2024-01-11 11:47:14 UTC
Created attachment 2400 [details]
master-adjust-logic-in-image_viewer_load_image.patch
Comment 2 Ricardo Mones 2024-01-12 12:32:00 UTC
Hi Olaf, the API doc for gdk_pixbuf_animation_new_from_stream says [1]:

> If NULL is returned, then error will be set.

And the error is checked after call, therefore should be not possible to reach the patched line with a NULL value in the animation variable.

That makes the check for animation nullness also unnecessary :)

[1] https://docs.gtk.org/gdk-pixbuf/ctor.PixbufAnimation.new_from_stream.html
Comment 3 olaf 2024-01-12 12:49:19 UTC
If that is the case, the check for animation==NULL could be removed. I think it needs careful reading of gdk_pixbuf_animation_new_from_stream, if it does indeed behave as documented in every code path.
Comment 4 olaf 2024-01-12 15:50:19 UTC
I think the intention of 05f600e5826ab4fd43e345b87bf1029c1fef48f7 and e121fc4767e57fd6018997b75d636264049c9ce8 was a warning from coverity, which can not know that gdk_pixbuf_animation_new_from_stream reports errors via the return value and the value of "error". Therefore I think my change fixes the compiler warning, the coverity warning and potential errors in gdk_pixbuf_animation_new_from_stream.

Note You need to log in before you can comment on or make changes to this bug.