diff --git a/src/jrd/SimilarToMatcher.h b/src/jrd/SimilarToMatcher.h index 117323ed57..558ead55d0 100644 --- a/src/jrd/SimilarToMatcher.h +++ b/src/jrd/SimilarToMatcher.h @@ -690,7 +690,7 @@ void SimilarToMatcher::Evaluator::parsePrimary(int* flag if (patternPos >= patternEnd) status_exception::raise(isc_invalid_similar_pattern, 0); - SLONG len = patternPos++ - start; + const SLONG len = patternPos++ - start; typedef const UCHAR* (TextType::*GetCanonicalFunc)(int*) const; @@ -1043,59 +1043,57 @@ bool SimilarToMatcher::Evaluator::match(int limit, int s case opAnyOf: if (bufferPos >= bufferEnd) return false; + + if (notInSet(bufferPos, 1, node->str, node->len) != 0) + { + const UCHAR* end = node->str2 + node->len2; + const UCHAR* p = node->str2; + + while (p < end) + { + UCHAR c[sizeof(ULONG)]; + ULONG len = charSet->substring( + buffer.getCount(), buffer.begin(), + sizeof(c), c, bufferPos - bufferStart, 1); + + if (textType->compare(len, c, p[0], p + 1) >= 0 && + textType->compare(len, c, p[1 + p[0]], p + 2 + p[0]) <= 0) + { + break; + } + + p += 2 + p[0] + p[1 + p[0]]; + } + + if (node->len + node->len2 != 0 && p >= end) + return false; + } + + if (notInSet(bufferPos, 1, node->str3, node->len3) == 0) + return false; else { - if (notInSet(bufferPos, 1, node->str, node->len) != 0) + const UCHAR* end = node->str4 + node->len4; + const UCHAR* p = node->str4; + + while (p < end) { - const UCHAR* end = node->str2 + node->len2; - const UCHAR* p = node->str2; + UCHAR c[sizeof(ULONG)]; + ULONG len = charSet->substring( + buffer.getCount(), buffer.begin(), + sizeof(c), c, bufferPos - bufferStart, 1); - while (p < end) + if (textType->compare(len, c, p[0], p + 1) >= 0 && + textType->compare(len, c, p[1 + p[0]], p + 2 + p[0]) <= 0) { - UCHAR c[sizeof(ULONG)]; - ULONG len = charSet->substring( - buffer.getCount(), buffer.begin(), - sizeof(c), c, bufferPos - bufferStart, 1); - - if (textType->compare(len, c, p[0], p + 1) >= 0 && - textType->compare(len, c, p[1 + p[0]], p + 2 + p[0]) <= 0) - { - break; - } - - p += 2 + p[0] + p[1 + p[0]]; + break; } - if (node->len + node->len2 != 0 && p >= end) - return false; + p += 2 + p[0] + p[1 + p[0]]; } - if (notInSet(bufferPos, 1, node->str3, node->len3) == 0) + if (p < end) return false; - else - { - const UCHAR* end = node->str4 + node->len4; - const UCHAR* p = node->str4; - - while (p < end) - { - UCHAR c[sizeof(ULONG)]; - ULONG len = charSet->substring( - buffer.getCount(), buffer.begin(), - sizeof(c), c, bufferPos - bufferStart, 1); - - if (textType->compare(len, c, p[0], p + 1) >= 0 && - textType->compare(len, c, p[1 + p[0]], p + 2 + p[0]) <= 0) - { - break; - } - - p += 2 + p[0] + p[1 + p[0]]; - } - - if (p < end) - return false; - } } ++bufferPos; diff --git a/src/remote/server.cpp b/src/remote/server.cpp index 82968698d9..5dfc37e64e 100644 --- a/src/remote/server.cpp +++ b/src/remote/server.cpp @@ -508,7 +508,7 @@ void SRVR_multi_thread( rem_port* main_port, USHORT flags) } if (dataSize) { - SSHORT asyncSize = port->asyncReceive(&asyncPacket, buffer, dataSize); + const SSHORT asyncSize = port->asyncReceive(&asyncPacket, buffer, dataSize); if (asyncSize == dataSize) { port = NULL; @@ -5224,7 +5224,8 @@ SSHORT rem_port::asyncReceive(PACKET* asyncPacket, const UCHAR* buffer, SSHORT d port_async_receive->receive(asyncPacket); } - SSHORT asyncSize = dataSize - port_async_receive->port_receive.x_handy; + const SSHORT asyncSize = dataSize - port_async_receive->port_receive.x_handy; + fb_assert(asyncSize >= 0); switch(asyncPacket->p_operation) {