diff --git a/engine/shared/library/sharedDatabaseInterface/src/shared/core/DbBindableString.h b/engine/shared/library/sharedDatabaseInterface/src/shared/core/DbBindableString.h index 7a1d2e04..c9552f0c 100755 --- a/engine/shared/library/sharedDatabaseInterface/src/shared/core/DbBindableString.h +++ b/engine/shared/library/sharedDatabaseInterface/src/shared/core/DbBindableString.h @@ -254,12 +254,11 @@ namespace DB if (bufsize >= S) { WARNING(true, ("Attmpted to insert %s which is too long. Truncating.", buffer)); indicator = S; - memcpy(m_value, buffer, indicator-1); } else { indicator = bufsize; - memcpy(m_value, buffer, indicator); } + memcpy(m_value, buffer, indicator); m_value[indicator] = '\0'; } @@ -274,10 +273,10 @@ namespace DB memcpy(m_value, Unicode::wideToNarrow(buffer).c_str(), indicator-1); } else { indicator = bufsize; - memcpy(m_value, Unicode::wideToNarrow(buffer).c_str(), indicator); } - m_value[indicator] = '\0'; + memcpy(m_value, Unicode::wideToNarrow(buffer).c_str(), indicator); + m_value[indicator] = '\0'; } template @@ -288,12 +287,12 @@ namespace DB if (bufsize >= S) { WARNING(true, ("Attmpted to insert %s which is too long. Truncating.", buffer.c_str())); indicator = S; - memcpy(m_value, buffer.c_str(), indicator-1); } else { indicator = bufsize; memcpy(m_value, buffer.c_str(), indicator); } + memcpy(m_value, buffer.c_str(), indicator); m_value[indicator] = '\0'; } diff --git a/engine/shared/library/sharedDatabaseInterface/src/shared/core/DbBindableUnicode.h b/engine/shared/library/sharedDatabaseInterface/src/shared/core/DbBindableUnicode.h index fba31be0..d8c761fc 100755 --- a/engine/shared/library/sharedDatabaseInterface/src/shared/core/DbBindableUnicode.h +++ b/engine/shared/library/sharedDatabaseInterface/src/shared/core/DbBindableUnicode.h @@ -200,12 +200,11 @@ namespace DB if (bufsize >= S) { WARNING(true, ("Attmpted to insert %s which is too long. Truncating.", buffer.c_str())); indicator = S; - memcpy(m_value, str.c_str(), indicator-1); } else { indicator = bufsize; - memcpy(m_value, str.c_str(), indicator); } - + + memcpy(m_value, str.c_str(), indicator); m_value[indicator] = '\0'; }