Re: pnm backend crashes graphical frontends (patch?)

From: Henning Meier-Geinitz (hmg-ml@gmx.de)
Date: Wed Sep 27 2000 - 11:59:59 PDT

  • Next message: Henning Meier-Geinitz: "Re: Problem with Mustek 6000CX"

    Hi,

    > It seemed, that the problem was a call to sane_read() in the
    > pnm backend, which ignored the value in max_length.
    > Therefore the buffer allocated by the frontend is just to
    > small sometimes.

    Ok, I can see the problem now. If max_length gets smaller, rgblength is not
    adjusted. I think a solution would be to add a

    "else rgblength = 3 * max_length;"

    after the "if (rgbbuf == 0 ...)" statement.

    > I'm not sure, whether my patch was just good luck,

    It wasn't. By setting rgblength to 0 it's reinitialized with each sane_read.

    > Finally I couldn't find a single reason, why this variable (and also
    > rgbbuf and rgbleftover) is static, so I moved it in sane_read().

    I haven't understood rgbleftover yet but it looks like it intentionally
    should keep its value between calls to sane_read.

    I will fix this in CVS (and "my" problem) after I understand all of this
    code.

    > > This reveals another problem: xscanimage doesn't test if it gets too much
    > > data from the backend (at least in preview mode).
    >
    > Are you sure?

    I am sure that this is a problem in case of a bad backend :-) It shouldn't
    hurt if the frontend checks if more data than the expected amount is
    provided by a backend (--> ignore the data, cancel the scan and print out
    some ugly messages). I would call this a nice feature for tracing problems
    with backends.

    > Is it really necessary that a frontend can handle scanning of a grayscale image
    > in three pass mode with a line number that isn't known a priori?

    If you want to conform to the SANE standard it's necessary. I think
    xscanimage and xsane can't cope with a variable length but scanimage can. At
    least xsane and xscanimage segfault ot produce pnms with a length of -1. I
    think the frontends should at least catch the "-1" and cancel the scan if
    they can't support variable length. I will add both points to the TODO list.

    > I'm just
    > wondering whether such a hardware exists ...

    I don't think there is something like a three pass handscanner but you
    never know :-)

    Bye,
      Henning

    --
    Source code, list archive, and docs: http://www.mostang.com/sane/
    To unsubscribe: echo unsubscribe sane-devel | mail majordomo@mostang.com
    



    This archive was generated by hypermail 2b29 : Wed Sep 27 2000 - 11:51:16 PDT