A truncated JPEG image presented to the Decompress method causes the .NET application to crash with error code 0xC0000374 (Heap Corruption).
When using the command line tool associated with libjpegturbo (djpeg.exe), the crash does not occur but you do get an error message "Premature end of JPEG file".
Updated: The problem seems to be in GetErrorAndThrow when calling TjGetErrorStr.
Updated: The following code seems to fix the issue:
public static void GetErrorAndThrow()
{
var errorPtr = TurboJpegImport.TjGetErrorStr();
var errorMessage = Marshal.PtrToStringAnsi(errorPtr);
throw new TJException(errorMessage);
}
OS: Windows 10
IDE: VS2015
TurboJpegWrapper Version: 1.5.55
.NET 4.5 (not Core and not Standard)
A truncated JPEG image presented to the Decompress method causes the .NET application to crash with error code 0xC0000374 (Heap Corruption).
When using the command line tool associated with libjpegturbo (djpeg.exe), the crash does not occur but you do get an error message "Premature end of JPEG file".
Updated: The problem seems to be in GetErrorAndThrow when calling TjGetErrorStr. Updated: The following code seems to fix the issue:
TurboJpegImport.cs
TjUtils.cs
OS: Windows 10 IDE: VS2015 TurboJpegWrapper Version: 1.5.55 .NET 4.5 (not Core and not Standard)