ref: 51b22d8548e61d3807b8b94e09d84f116ca0eb1c
parent: 31eb1b9d724ab8395d1191db083cabbb0d8b3bbe
author: Alex Musolino <alex@musolino.id.au>
date: Sat Oct 31 11:44:49 EDT 2020
jpg: treat EOF as EOI marker Some jpegs, rightly or wrongly, do not contain an EOI marker. This causes jpg(1) to bail out even after correctly parsing the entire image.
--- a/sys/src/cmd/jpg/readjpg.c
+++ b/sys/src/cmd/jpg/readjpg.c
@@ -389,8 +389,12 @@
if(h->peek >= 0){
x = h->peek;
h->peek = -1;
- }else if(Bread(h->fd, &x, 1) != 1)
- jpgerror(h, readerr);
+ }else
+ switch(Bread(h->fd, &x, 1)){
+ case 0: return -1;
+ case 1: break;
+ default: jpgerror(h, readerr);
+ }
return x;
}
@@ -403,6 +407,8 @@
Again:
while((c=readbyte(h)) == 0)
;
+ if(c < 0)
+ return EOI;
if(c != 0xFF)
goto Again;
while(c == 0xFF)