Giter Club home page Giter Club logo

Comments (3)

nigeltao avatar nigeltao commented on May 24, 2024

The PNG decoder still loops around "short read" in one place.

Can you elaborate on (1) where is this one place and (2) why this is a problem?

If the answer to (1) is in decoder.do_decode_frame line 1248 then decoder.decode_frame should 'catch' it and turn it into "truncated input".

DecodeImage0 doesn't reflect this change (no DecodeImage_UnexpectedEndOfFile as far as I can tell).

Yeah, DecodeImage_UnexpectedEndOfFile ought to be unreachable now. We could probably remove it in v0.4.

All decoders have their own version of this error, is that necessary?

Go isn't Wuffs, but in the Go standard library, we returned a common error (io.ErrUnexpectedEOF) instead of each image decoder having their own version of this error. This was apparently confusing / surprising, so it's the other way round in Wuffs.

from wuffs.

pjanx avatar pjanx commented on May 24, 2024

Can you elaborate on (1) where is this one place and (2) why this is a problem?

https://github.com/google/wuffs/blob/main/std/png/decode_png.wuffs#L1237

Inconsistency. I haven't retested what actually happens, I've just reread the code.

This was apparently confusing / surprising, so it's the other way round in Wuffs.

This particular argument doesn't convince me. The thread is about people trying to receive as much of an image as they can, and dealing with the possibility of receiving an error (warning) at the same time.

from wuffs.

nigeltao avatar nigeltao commented on May 24, 2024

https://github.com/google/wuffs/blob/main/std/png/decode_png.wuffs#L1237

OK that (line 1237) rolls into line 1248 that I referenced above. I suppose we could make line 1248 return "#truncated input" directly, which would be a little cleaner. As I said, though, decoder.decode_frame should already 'catch' "$short read", so it shouldn't make a difference, in practice.

This particular argument doesn't convince me.

If you're not convinced then we'll agree to disagree. I'm just telling you why it's the way it is.

The thread is about people trying to receive as much of an image as they can, and dealing with the possibility of receiving an error (warning) at the same time.

There's two concerns in that thread. One is about trying to receive as much of an image as they can, as you said. Two is about what error you get when it's truncated (a generic io error versus an image-format-specific jpeg error) which is relevant to your "All decoders have their own version of this error, is that necessary?" in the OP. A quote from that thread: "How do I know that io.ErrUnexpectedEOF has anything to do with "wrong" JPEGs?"

from wuffs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.