GNU bug report logs -
#19208
replace-match unhelpful error message
Previous Next
Reported by: phillip.lord <at> newcastle.ac.uk (Phillip Lord)
Date: Fri, 28 Nov 2014 17:01:02 UTC
Severity: minor
Tags: fixed
Fixed in version 27.1
Done: Lars Ingebrigtsen <larsi <at> gnus.org>
Bug is archived. No further changes may be made.
Full log
Message #15 received at 19208 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
> No, that's just another sanity check -- num_regs is the max allowed
> number of sub-matches. (I've now added some comments to clarify.)
Unfortunately that patch messes up the sanity check, as the patched code allows
'sub' to be negative, or to be equal to search_regs.num_regs, and in either case
this results in a bad pointer.
> Yoda conditionals and a !...
Actually those were Leibniz conditionals, which are comparisons involving "<" or
"<=". The idea is that the conditionals' textual order reflects numeric order.
This is a common style in math when doing range checking, e.g., "0 <= i < n".
Yoda conditionals are expressions like "0 != x" which I agree are confusing.
I learned Leibniz conditionals from the late Val Schorre, who was *really* good
at programming and programming style: Knuth credits Schorre with the invention
of goto-less programming in the early 1960s. When I redid your patch as a
Leibniz conditional, I instantly spotted the bug that it introduced. You might
give Leibniz conditionals a try, as they help make code more readable and
reliable when checking for range errors or overflow.
While in the neighborhood I spotted some other rare possibilities for bad
behavior due to out-of-range indexes. I fixed the bugs I found by installing the
attached.
[0001-Fix-rare-undefined-behaviors-in-replace-match.patch (text/x-patch, attachment)]
This bug report was last modified 5 years and 296 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.