<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>246248</bug_id>
          
          <creation_ts>2022-10-08 06:18:48 -0700</creation_ts>
          <short_desc>[GLib] JPEG2000 decoder produces warning about  maybe uninitialized variable</short_desc>
          <delta_ts>2022-10-18 07:35:20 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Images</component>
          <version>WebKit Nightly Build</version>
          <rep_platform>Unspecified</rep_platform>
          <op_sys>Unspecified</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>InRadar</keywords>
          <priority>P2</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Adrian Perez">aperez</reporter>
          <assigned_to name="Adrian Perez">aperez</assigned_to>
          <cc>cgarcia</cc>
    
    <cc>sabouhallawa</cc>
    
    <cc>webkit-bug-importer</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>1904247</commentid>
    <comment_count>0</comment_count>
    <who name="Adrian Perez">aperez</who>
    <bug_when>2022-10-08 06:18:48 -0700</bug_when>
    <thetext>Caught by Clang with -Werror=conditional-uninitialized, inside JPEG2000Decoder::decode():

/app/webkit/Source/WebCore/platform/image-decoders/jpeg2000/JPEG2000ImageDecoder.cpp:546:56: error: variable &apos;a&apos; may be uninitialized when used here [-Werror,-Wconditional-uninitialized]
            int adjustedAlpha = image-&gt;numcomps &gt; 3 ? (a &gt;&gt; adjust[3]) + ((a &gt;&gt; (adjust[3] - 1)) % 2) : 0xFF;
                                                       ^
/app/webkit/Source/WebCore/platform/image-decoders/jpeg2000/JPEG2000ImageDecoder.cpp:506:27: note: initialize the variable &apos;a&apos; to silence this warning
            int r, g, b, a;
                          ^
                           = 0
1 error generated.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1904248</commentid>
    <comment_count>1</comment_count>
    <who name="Adrian Perez">aperez</who>
    <bug_when>2022-10-08 06:20:44 -0700</bug_when>
    <thetext>Now that I think of it... The mishandling of alpha might related to the
decoding artifacts reported in bug #244528 (or at least be part of the
issue).</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1904277</commentid>
    <comment_count>2</comment_count>
    <who name="Adrian Perez">aperez</who>
    <bug_when>2022-10-08 12:47:08 -0700</bug_when>
    <thetext>Pull request: https://github.com/WebKit/WebKit/pull/5166</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1904278</commentid>
    <comment_count>3</comment_count>
    <who name="Adrian Perez">aperez</who>
    <bug_when>2022-10-08 12:49:36 -0700</bug_when>
    <thetext>(In reply to Adrian Perez from comment #1)
&gt; Now that I think of it... The mishandling of alpha might related to the
&gt; decoding artifacts reported in bug #244528 (or at least be part of the
&gt; issue).

*Narrator voice*: It wasn´t.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1904324</commentid>
    <comment_count>4</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2022-10-09 02:21:24 -0700</bug_when>
    <thetext>I don&apos;t see how this can happen because a is initialized when image-&gt;numcomps &gt; 3 and only used when image-&gt;numcomps &gt; 3 too.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1906433</commentid>
    <comment_count>5</comment_count>
    <who name="Adrian Perez">aperez</who>
    <bug_when>2022-10-18 06:00:45 -0700</bug_when>
    <thetext>(In reply to Carlos Garcia Campos from comment #4)
&gt; I don&apos;t see how this can happen because a is initialized when
&gt; image-&gt;numcomps &gt; 3 and only used when image-&gt;numcomps &gt; 3 too.

I took another look at the code and you are right, but of course
the compiler cannot completely reason about the code and produces
a warning... so in the end I am only silencing the warning in my
patch 🤦️

Still, I think we can merge it to contribute a bit to cleaner
build output logs.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1906438</commentid>
    <comment_count>6</comment_count>
    <who name="Carlos Garcia Campos">cgarcia</who>
    <bug_when>2022-10-18 06:14:58 -0700</bug_when>
    <thetext>Sure, it doesn&apos;t hurt, but let&apos;s change the bug title and commit message to make it clear it&apos;s not fixing anything, but just silencing a warning.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1906457</commentid>
    <comment_count>7</comment_count>
    <who name="EWS">ews-feeder</who>
    <bug_when>2022-10-18 07:34:24 -0700</bug_when>
    <thetext>Committed 255674@main (9a76ccc77f6e): &lt;https://commits.webkit.org/255674@main&gt;

Reviewed commits have been landed. Closing PR #5166 and removing active labels.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>1906458</commentid>
    <comment_count>8</comment_count>
    <who name="Radar WebKit Bug Importer">webkit-bug-importer</who>
    <bug_when>2022-10-18 07:35:20 -0700</bug_when>
    <thetext>&lt;rdar://problem/101290537&gt;</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>