Prevent infinite loop when scanning for endstream (bug 1020226)

*Note:* even with this patch, the file referenced in the bug still doesn't load in PDF.js. However I think this is OK, since even Adobe Reader won't open the file (it just displays a message saying that the file is damaged).
Let's use `scanLength <= 0` here