Bug 246248

Summary: [GLib] JPEG2000 decoder produces warning about maybe uninitialized variable
Product: WebKit Reporter: Adrian Perez <aperez>
Component: ImagesAssignee: Adrian Perez <aperez>
Status: RESOLVED FIXED    
Severity: Normal CC: cgarcia, sabouhallawa, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Adrian Perez
Reported 2022-10-08 06:18:48 PDT
Caught by Clang with -Werror=conditional-uninitialized, inside JPEG2000Decoder::decode(): /app/webkit/Source/WebCore/platform/image-decoders/jpeg2000/JPEG2000ImageDecoder.cpp:546:56: error: variable 'a' may be uninitialized when used here [-Werror,-Wconditional-uninitialized] int adjustedAlpha = image->numcomps > 3 ? (a >> adjust[3]) + ((a >> (adjust[3] - 1)) % 2) : 0xFF; ^ /app/webkit/Source/WebCore/platform/image-decoders/jpeg2000/JPEG2000ImageDecoder.cpp:506:27: note: initialize the variable 'a' to silence this warning int r, g, b, a; ^ = 0 1 error generated.
Attachments
Adrian Perez
Comment 1 2022-10-08 06:20:44 PDT
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).
Adrian Perez
Comment 2 2022-10-08 12:47:08 PDT
Adrian Perez
Comment 3 2022-10-08 12:49:36 PDT
(In reply to Adrian Perez from comment #1) > 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). *Narrator voice*: It wasn´t.
Carlos Garcia Campos
Comment 4 2022-10-09 02:21:24 PDT
I don't see how this can happen because a is initialized when image->numcomps > 3 and only used when image->numcomps > 3 too.
Adrian Perez
Comment 5 2022-10-18 06:00:45 PDT
(In reply to Carlos Garcia Campos from comment #4) > I don't see how this can happen because a is initialized when > image->numcomps > 3 and only used when image->numcomps > 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.
Carlos Garcia Campos
Comment 6 2022-10-18 06:14:58 PDT
Sure, it doesn't hurt, but let's change the bug title and commit message to make it clear it's not fixing anything, but just silencing a warning.
EWS
Comment 7 2022-10-18 07:34:24 PDT
Committed 255674@main (9a76ccc77f6e): <https://commits.webkit.org/255674@main> Reviewed commits have been landed. Closing PR #5166 and removing active labels.
Radar WebKit Bug Importer
Comment 8 2022-10-18 07:35:20 PDT
Note You need to log in before you can comment on or make changes to this bug.