Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
/goPublic

Commitbff99b6

Browse files
committed
[release-branch.go1] image/jpeg: ignore an incorrect but harmless trailing restart marker.
««« backport 7af3dbecf445image/jpeg: ignore an incorrect but harmless trailing restart marker.Fixes#4084.R=rCC=golang-devhttps://golang.org/cl/6526043»»»
1 parent4ecd79f commitbff99b6

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

‎src/pkg/image/jpeg/reader.go‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,15 @@ func (d *decoder) decode(r io.Reader, configOnly bool) (image.Image, error) {
396396
ifmarker==eoiMarker {// End Of Image.
397397
break
398398
}
399+
ifrst0Marker<=marker&&marker<=rst7Marker {
400+
// Figures B.2 and B.16 of the specification suggest that restart markers should
401+
// only occur between Entropy Coded Segments and not after the final ECS.
402+
// However, some encoders may generate incorrect JPEGs with a final restart
403+
// marker. That restart marker will be seen here instead of inside the processSOS
404+
// method, and is ignored as a harmless error. Restart markers have no extra data,
405+
// so we check for this before we read the 16-bit length of the segment.
406+
continue
407+
}
399408

400409
// Read the 16-bit length of the segment. The value includes the 2 bytes for the
401410
// length itself, so we subtract 2 to get the number of remaining bytes.
@@ -424,7 +433,7 @@ func (d *decoder) decode(r io.Reader, configOnly bool) (image.Image, error) {
424433
err=d.processSOS(n)
425434
casemarker==driMarker:// Define Restart Interval.
426435
err=d.processDRI(n)
427-
casemarker>=app0Marker&&marker<=app15Marker||marker==comMarker:// APPlication specific, or COMment.
436+
caseapp0Marker<=marker&&marker<=app15Marker||marker==comMarker:// APPlication specific, or COMment.
428437
err=d.ignore(n)
429438
default:
430439
err=UnsupportedError("unknown marker")

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp