You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/ImageSharp/Formats/Tiff/Compression/Decompressors/LzwString.cs
+16-8Lines changed: 16 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -69,25 +69,33 @@ public int WriteTo(Span<byte> buffer, int offset)
69
69
return0;
70
70
}
71
71
72
-
if(this.Length==1)
72
+
intavailable=buffer.Length-offset;
73
+
if(available<=0)
73
74
{
74
-
buffer[offset]=this.value;
75
-
return1;
75
+
return0;
76
+
}
77
+
78
+
intnumToWrite=this.Length;
79
+
if(numToWrite>available)
80
+
{
81
+
numToWrite=available;
76
82
}
77
83
78
84
LzwStringe=this;
79
-
intendIdx=this.Length-1;
80
-
if(offset+endIdx>=buffer.Length)
85
+
86
+
// if string is too long, skip bytes at the end
87
+
inttoSkip=this.Length-numToWrite;
88
+
for(inti=0;i<toSkip;i++)
81
89
{
82
-
TiffThrowHelper.ThrowImageFormatException("Error reading lzw compressed stream. Either pixel buffer to write to is too small or code length is invalid!");
0 commit comments