[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [lmi] Group quote PDF: segfault on strlen

From: Greg Chicares
Subject: Re: [lmi] Group quote PDF: segfault on strlen
Date: Wed, 8 Mar 2017 22:04:05 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.6.0

On 2017-03-08 21:18, Vadim Zeitlin wrote:
>  It's not urgent to do anything about it, of course, but, just
> for the record, I think there are 2 ways to improve things here:
> 1. Simple and direct: replace the loop with "for(auto const& f: fields)"
>    and then open/close the "tr" tag inside the loop, using a counter
>    (defined outside the loop, of course). The problem with this one is
>    that it would still to be simple to make a mistake with opening/closing
>    this tag and it would still be bad, even though (or maybe especially
>    because?) such a mistake wouldn't result in a crash any more (but "just"
>    wrong output).
> 2. Higher level and more functional: iterate over pairs of fields, i.e.
>    replace the loop with "for(auto const& pair: view_by_pairs(fields))".
>    This would be, IMO, preferable, but does require writing our own
>    view_by_pairs() helper because we're not going to start using a big new
>    library just for this.

What about...

3. Pad the container of fields (with something that will print as blank)
as necessary in order to establish the invariant that the cardinality
is always even. Then use simple, direct logic as in (1) above, except that
the logic can be even simpler because we'd never print N-and-a-half pairs.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]