Coverity check please...
Gary E. Miller
gem at rellim.com
Mon Jan 20 23:56:25 UTC 2025
Yo Hal!
On Mon, 20 Jan 2025 15:39:37 -0800
Hal Murray <halmurray at sonic.net> wrote:
> > Still seems like a bug to me. Any potential UB is bad. Should be
> > easy to work around.
>
> Please look at the code. It's only 10 lines.
I did.
> If you can suggest a fix, I'll try it.
Check for the underflow/overflow before the subtraction.
> 473 while ((j - i) > m) {
while (1) {
if (j <= i) {
/* avoid integer wraparound
* also if j == i, then (j - i) == 0 and 0 can not
* be > m */
break;
}
if ((j - i) <= m) {
// done.
break;
}
RGDS
GARY
---------------------------------------------------------------------------
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703
gem at rellim.com Tel:+1 541 382 8588
Veritas liberabit vos. -- Quid est veritas?
"If you can't measure it, you can't improve it." - Lord Kelvin
More information about the devel
mailing list