Skip to content

Commit

Permalink
adding exception handling for corrupt images
Browse files Browse the repository at this point in the history
acruikshank committed Nov 19, 2012
1 parent bd858c6 commit bbbc437
Showing 3 changed files with 28 additions and 18 deletions.
Binary file added images/broken.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions png-node.coffee
Original file line number Diff line number Diff line change
@@ -113,6 +113,9 @@ module.exports = class PNG

@pos += 4 # Skip the CRC

if @pos > @data.length
throw new Error "Incomplete or corrupt PNG file"

return

read: (bytes) ->
43 changes: 25 additions & 18 deletions png-node.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bbbc437

Please sign in to comment.