Closed Bug 243763 Opened 20 years ago Closed 11 years ago

warning C4244: '=' : conversion from 'LONG' to 'PRInt8', possible loss of data

Categories

(Core :: Graphics: ImageLib, defect, P5)

x86
Windows XP
defect

Tracking

()

RESOLVED FIXED
mozilla21

People

(Reporter: timeless, Assigned: filidautore)

References

(Blocks 1 open bug, )

Details

(Whiteboard: [build_warning])

Attachments

(1 file, 1 obsolete file)

r:/mozilla\modules\libpr0n\decoders\icon\win\nsIconChannel.cpp(307) : warning 
C4244: '=' : conversion from 'LONG' to 'PRInt8', possible loss of data
r:/mozilla\modules\libpr0n\decoders\icon\win\nsIconChannel.cpp(308) : warning 
C4244: '=' : conversion from 'LONG' to 'PRInt8', possible loss of data
Because of the API used we know that the icon can't have dimensions out of
bounds, right? So we just need to shut up the compiler?
Status: UNCONFIRMED → NEW
Ever confirmed: true
Priority: -- → P5
QA Contact: imagelib
Whiteboard: [build_warning]
Blocks: buildwarning
Still an issue, though the code has moved:
e:/builds/moz2_slave/m-cen-w32/build/image/decoders/icon/win/nsIconChannel.cpp(561) : warning C4244: '=' : conversion from 'LONG' to 'PRInt8', possible loss of data

e:/builds/moz2_slave/m-cen-w32/build/image/decoders/icon/win/nsIconChannel.cpp(562) : warning C4244: '=' : conversion from 'LONG' to 'PRInt8', possible loss of data
Attached patch Make the cast explicit (obsolete) — Splinter Review
I only made the cast explicit.
Attachment #699195 - Flags: review?(joe)
Comment on attachment 699195 [details] [diff] [review]
Make the cast explicit

Review of attachment 699195 [details] [diff] [review]:
-----------------------------------------------------------------

While this code looks great, I don't know enough about GetDIBits to comment on whether it's actually not going to overflow - i.e., whether we have a latent bug here.
Attachment #699195 - Flags: review?(joe) → review?(netzen)
(In reply to Joe Drew from comment #4)
> While this code looks great, I don't know enough about GetDIBits to comment
> on whether it's actually not going to overflow - i.e., whether we have a
> latent bug here.

Seems legit, the bitmap came from an HICON in the first place.
Comment on attachment 699195 [details] [diff] [review]
Make the cast explicit

Review of attachment 699195 [details] [diff] [review]:
-----------------------------------------------------------------

Thanks for the patch!

I think GetIconInfo will always return handles to bitmaps that have the correct dimensions but we might as well add some sanity checks while we're here.

Could you add some extra checks here:
http://dxr.mozilla.org/mozilla-central/image/decoders/icon/win/nsIconChannel.cpp.html#l489

colorHeader.biWidth >= 0 && colorHeader.biWidth <= 255 &&
colorHeader.biHeight >= 0 && colorHeader.biHeight <= 255 &&

Re-request review after that and we should be good to land this patch.
Attachment #699195 - Flags: review?(netzen) → feedback+
Attachment #700283 - Flags: review?(netzen)
Comment on attachment 700283 [details] [diff] [review]
Make the cast explicit, plus feedback

Review of attachment 700283 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good, I'll run it through try and if it passes we can land it!
Thanks again for the patch.
Attachment #700283 - Flags: review?(netzen) → review+
Attachment #699195 - Attachment is obsolete: true
https://hg.mozilla.org/mozilla-central/rev/9c2be62cb0c0
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Assignee: neil → filidautore
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: