OSDN Git Service

Make sure Keccak state gets allocated aligned to 32.
authorLoRd_MuldeR <mulder2@gmx.de>
Thu, 17 Oct 2013 23:58:29 +0000 (01:58 +0200)
committerLoRd_MuldeR <mulder2@gmx.de>
Thu, 17 Oct 2013 23:58:29 +0000 (01:58 +0200)
etc/Prerequisites/keccak/src/qkeccakhash.cpp

index 42a088d..bba43dc 100644 (file)
 QKeccakHash::QKeccakHash()
 {
        m_initialized = false;
-       m_state = new KeccakImpl::hashState;
+       m_state = (KeccakImpl::hashState*) _aligned_malloc(sizeof(KeccakImpl::hashState), 32);
+       if(!m_state)
+       {
+               throw "[QKeccakHash] Error: _aligned_malloc() has failed, probably out of heap space!";
+       }
        memset(m_state, 0, sizeof(KeccakImpl::hashState));
        m_hashResult.clear();
 }
@@ -42,7 +46,7 @@ QKeccakHash::~QKeccakHash()
 
        if(m_state)
        {
-               delete m_state;
+               _aligned_free(m_state);
                m_state = NULL;
        }
 }