If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
cutecode
Super wx Problem Solver
Posts: 425 Joined: Fri Dec 09, 2016 7:28 am
Contact:
Post
by cutecode » Fri Mar 31, 2023 7:24 am
How to check if image file is wrong before loading it with wxImage::LoadFile?
My program crashes if file is wrong
7Y1Ns-B7Uv2-27hPH-J2ibo.gif (32.27 KiB) Viewed 3355 times
All prgograms are showing this file without any error
Why wxImage::LoadFile crashes?
PB
Part Of The Furniture
Posts: 4193 Joined: Sun Jan 03, 2010 5:45 pm
Post
by PB » Fri Mar 31, 2023 8:21 am
cutecode wrote: ↑ Fri Mar 31, 2023 7:24 am
Why wxImage::LoadFile crashes?
Probably due to to a bug in wxGIFDecoder::getcode(), where it tries to write many more bytes to the buffer than the buffer actually has (in your image 4294967295 vs 256).
Will you report this bug or should I do it?
cutecode
Super wx Problem Solver
Posts: 425 Joined: Fri Dec 09, 2016 7:28 am
Contact:
Post
by cutecode » Fri Mar 31, 2023 8:31 am
I don't know how to do it.
I would be grateful if you do it.
Thank you.
PB
Part Of The Furniture
Posts: 4193 Joined: Sun Jan 03, 2010 5:45 pm
Post
by PB » Fri Mar 31, 2023 9:19 am
cutecode
Super wx Problem Solver
Posts: 425 Joined: Fri Dec 09, 2016 7:28 am
Contact:
Post
by cutecode » Fri Mar 31, 2023 9:32 am
WOW
Thank you.
Nice full description.
PB
Part Of The Furniture
Posts: 4193 Joined: Sun Jan 03, 2010 5:45 pm
Post
by PB » Fri Mar 31, 2023 9:58 am
I have also provided a blind fix, but it needs to be applied to wxWidgets code, can't be used from the user code.
ONEEYEMAN
Part Of The Furniture
Posts: 7461 Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine
Post
by ONEEYEMAN » Fri Mar 31, 2023 12:34 pm
Alex,
Since the fix is blind - can you apply it to your local copy and see if it fixes the crash for you?
Thank you.
cutecode
Super wx Problem Solver
Posts: 425 Joined: Fri Dec 09, 2016 7:28 am
Contact:
Post
by cutecode » Fri Mar 31, 2023 1:37 pm
Thank you this patch did help
I don't have any warning maybe because I put this line before LoadFile()
im.SetLoadFlags(im.GetLoadFlags() & ~wxImage::Load_Verbose);
Code: Select all
wxImage im;
im.SetLoadFlags(im.GetLoadFlags() & ~wxImage::Load_Verbose);
if(im.LoadFile(sz))
ONEEYEMAN
Part Of The Furniture
Posts: 7461 Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine
Post
by ONEEYEMAN » Fri Mar 31, 2023 1:41 pm
Hi,
Is the image displayed or it just doesn't crash?
Thank you.
cutecode
Super wx Problem Solver
Posts: 425 Joined: Fri Dec 09, 2016 7:28 am
Contact:
Post
by cutecode » Fri Mar 31, 2023 1:50 pm
It's partially displayed