1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-12-08 02:15:08 +00:00
freebsd-ports/security/cryptopp/files/patch-nbtheory.cpp
Xin LI 4fa5971018 This changeset fixes two issues with crypto++ library:
* patch-misc.h

   This fixes a warning triggered by testing an unsigned parameter against
   0.  The patch solves this by creating a different template for signed
   case.

 * patch-nbtheory.cpp

   This is a workaround for a bug with the current version of libc++ shipped
   with FreeBSD 9.x, which causes an infinite loop when generating RSA key,
   possibly also other operations.

PR:		ports/178827
Submitted by:	Michael Gmelin <freebsd grem de>
2013-05-22 22:41:42 +00:00

22 lines
741 B
C++

--- nbtheory.cpp.orig 2013-05-22 00:16:26.761193859 +0000
+++ nbtheory.cpp 2013-05-22 00:15:29.401256454 +0000
@@ -307,7 +307,18 @@
bool PrimeSieve::NextCandidate(Integer &c)
{
+#if defined(__clang__) && defined(_LIBCPP_VERSION) && _LIBCPP_VERSION < 1101
+ // Workaround for a bug in libc++ in std::find on std::vector<bool>
+ std::vector<bool>::iterator pos = m_sieve.begin()+m_next;
+ for (std::vector<bool>::iterator end = m_sieve.end(); pos != end; ++pos)
+ {
+ if (*pos == false)
+ break;
+ }
+ bool safe = SafeConvert(pos - m_sieve.begin(), m_next);
+#else
bool safe = SafeConvert(std::find(m_sieve.begin()+m_next, m_sieve.end(), false) - m_sieve.begin(), m_next);
+#endif
assert(safe);
if (m_next == m_sieve.size())
{