Bug? LoadImage() causes program to crash
Posted: Mon Feb 15, 2010 7:49 pm
Wow, I needed at least 2 hours (because first I was on a wrong track) to reproduce the error I get with this code:
The following normal image that I corrupt with the code causes the crash in my program:
http://em.q-soft.ch/filestore/a4/hyrC4BGV1j.image.jpg._
It's possible to create the crash in two ways: By using a combination of image decoders and by corrupting the image.
Anyway I learned to post it in the discussion first because maybe I mixed something up again.
Code: Select all
#File = "C:\image.jpg" ; I'm using this: http://em.q-soft.ch/filestore/a4/hyrC4BGV1j.image.jpg._
; Insert those lines to get the 2. crash
;UseJPEGImageDecoder()
;UsePNGImageDecoder()
UseTGAImageDecoder()
UseJPEG2000ImageDecoder()
; Make a backup
CopyFile(#File, #File + ".bak")
; Load normal image
ImageID = LoadImage(#PB_Any, #File) ; <- 1. Crash: "Read error at address 12813"
If ImageID <> 0
FreeImage(ImageID)
Debug "Load normal - Ok"
Else
Debug "Load normal - Error"
EndIf
; Make image corrupt
FileID = OpenFile(#PB_Any, #File)
If FileID <> 0
FileSeek(FileID, 23)
WriteByte(FileID, $F9) ; (Wrong marker size, correct is $6E)
CloseFile(FileID)
EndIf
; Load corrupt image
ImageID = LoadImage(#PB_Any, #File) ; <- 2. Crash: "Read error at address 12813"
If ImageID <> 0
FreeImage(ImageID)
Debug "Load corrupt - Ok"
Else
Debug "Load corrupt - Error"
EndIf
; Backup - you won't get here anyway because of the crashs ;)
DeleteFile(#File)
RenameFile(#File + ".bak", #File)
http://em.q-soft.ch/filestore/a4/hyrC4BGV1j.image.jpg._
It's possible to create the crash in two ways: By using a combination of image decoders and by corrupting the image.
Anyway I learned to post it in the discussion first because maybe I mixed something up again.