Bug 246248
| Summary: | [GLib] JPEG2000 decoder produces warning about maybe uninitialized variable | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Adrian Perez <aperez> |
| Component: | Images | Assignee: | 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
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 | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Adrian Perez
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
Pull request: https://github.com/WebKit/WebKit/pull/5166
Adrian Perez
(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
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
(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
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
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
<rdar://problem/101290537>