Input code
SixLabors.ImageSharp 4.1.1, SixLabors.ImageSharp.Formats.Png.PngEncoderCore.WriteXmpChunk (and
WriteExifChunk, same shape):
ilspycmd ~/.cache/nugetfuzz/sixlabors.imagesharp/4.1.1/lib/net8.0/SixLabors.ImageSharp.dll \
-t SixLabors.ImageSharp.Formats.Png.PngEncoderCore
Erroneous output
Current master (dbf23c6):
byte[] data = meta.XmpProfile.Data;
int? num = data?.Length;
if ((num ?? 0) == 0)
{
return;
}
With #4091 (6fcb387) the lifted comparison is expanded and wrapped in a no-op conditional:
byte[] data = meta.XmpProfile.Data;
int? num = data?.Length;
if ((!num.HasValue || num.GetValueOrDefault() == 0) ? true : false)
{
return;
}
Two separate things happen here: the ?? form is lost, and the resulting bool expression gains a
? true : false.
Other instances from the same corpus run (top-200 nuget.org packages, #4091 against its merge base):
- Swashbuckle.AspNetCore.SwaggerGen 10.2.3,
XmlCommentsRequestBodyFilter:
if ((num2 ?? 1) == 0 || num == 0) becomes
if ((num2.HasValue && num2.GetValueOrDefault() == 0) || num == 0)
OpenTelemetry.Exporter.OpenTelemetryProtocol serializer:
((statusCode ?? StatusCode.Unset) != StatusCode.Unset) becomes
(statusCode.HasValue && statusCode.GetValueOrDefault() != StatusCode.Unset)
Details
- Product in use: ICSharpCode.Decompiler, built from source
- Version in use: not reproducible on master (dbf23c6); measured at 6fcb387 against merge base
712ad1a. Three types in the corpus are affected; the output remains correct.
Filed by an AI agent (Claude) on Siegfried's behalf.
Input code
SixLabors.ImageSharp 4.1.1,
SixLabors.ImageSharp.Formats.Png.PngEncoderCore.WriteXmpChunk(andWriteExifChunk, same shape):Erroneous output
Current master (dbf23c6):
With #4091 (6fcb387) the lifted comparison is expanded and wrapped in a no-op conditional:
Two separate things happen here: the
??form is lost, and the resulting bool expression gains a? true : false.Other instances from the same corpus run (top-200 nuget.org packages, #4091 against its merge base):
XmlCommentsRequestBodyFilter:if ((num2 ?? 1) == 0 || num == 0)becomesif ((num2.HasValue && num2.GetValueOrDefault() == 0) || num == 0)OpenTelemetry.Exporter.OpenTelemetryProtocolserializer:((statusCode ?? StatusCode.Unset) != StatusCode.Unset)becomes(statusCode.HasValue && statusCode.GetValueOrDefault() != StatusCode.Unset)Details
712ad1a. Three types in the corpus are affected; the output remains correct.
Filed by an AI agent (Claude) on Siegfried's behalf.