gif: avoid stack underflow
[rsc] --rw-rw-r-- M 1115807 glenda sys 10472 Mar 24 12:22 sys/src/cmd/jpg/readgif.c
/n/sourcesdump/2006/0324/plan9/sys/src/cmd/jpg/readgif.c:451,457 -
/n/sourcesdump/2006/0325/plan9/sys/src/cmd/jpg/readgif.c:451,457
fprint(2, "ReadGIF: GIF invalid, code out of range, %x > %x\n", code, nentry);
code = nentry;
}
- for(c=code; c>=0; c=tbl[c].prefix)
+ for(c=code; stacki>0 && c>=0; c=tbl[c].prefix)
stack[stacki--] = tbl[c].exten;
nb = (sizeof stack)-(stacki+1);
|