From: Guy Harris Date: Thu, 3 Oct 2019 16:27:36 +0000 (-0700) Subject: With MSVC, abort if _BitScanForward() returns 0. X-Git-Tag: libpcap-1.10-bp~413 X-Git-Url: https://git.tcpdump.org/libpcap/commitdiff_plain/3b9b6100912f7bb1ee43f9cfb51e804765a37bd4 With MSVC, abort if _BitScanForward() returns 0. It should never return zero, as never pass a value of 0 to lowest_set_bit(), but this should keep Coverity from getting upset (as a result of not understanding _BitScanForward() well enough to realize that if it's passed a non-zero value it will never return 0). Reported by Charles Smith at Tangible Security. --- diff --git a/optimize.c b/optimize.c index 283a6de3..e38d2d7c 100644 --- a/optimize.c +++ b/optimize.c @@ -137,7 +137,7 @@ lowest_set_bit(int mask) * (It's currently not, in MSVC, even on 64-bit platforms, but....) */ if (_BitScanForward(&bit, (unsigned int)mask) == 0) - return -1; /* mask is zero */ + abort(); /* mask is zero */ return (int)bit; } #elif defined(MSDOS) && defined(__DJGPP__)