recent coverity and rand

Tor Lillqvist tml at iki.fi
Tue Oct 7 00:18:53 PDT 2014


> FYI, this change
>
>  double random(double min, double max)
>  {
> -    return floor(((double)rand() / ((unsigned int)RAND_MAX + 1)) * (max -
> min + 1) + min);
> +    return comphelper::rng::uniform_real_distribution(min, max);
>  }
>
> in sc/source/core/opencl/opencl_device.cxx has made the opencl cppunit
> test run extremely slow, if not hanging.


The problem was that it called  comphelper::rng::uniform_real_distribution()
with two equal arguments, which is invalid use of that API, and causes the
current implementation to get stuck in a loop in the boost code. (I didn't
bother checking whether it is possible that the loop eventually will exit.)
Fixed with 4bb67e666b2ca36a5caa5c3f22d0f1e802db527e
and 1b226b02471f2fab5e5e6f79b6593636274d2320 .

--tml
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20141007/8cb26d8a/attachment.html>


More information about the LibreOffice mailing list