From b401c07a07c37df7310dfbd0066e4d157dc01a19 Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Fri, 2 Oct 2015 17:44:14 +0000 Subject: SpellChecker: coverity fixes git-svn-id: http://svn.miranda-ng.org/main/trunk@15495 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/SpellChecker/src/RichEdit.cpp | 7 ++++--- plugins/SpellChecker/src/utils.cpp | 8 ++------ 2 files changed, 6 insertions(+), 9 deletions(-) (limited to 'plugins/SpellChecker') diff --git a/plugins/SpellChecker/src/RichEdit.cpp b/plugins/SpellChecker/src/RichEdit.cpp index b6b0f7ba73..0fdcf62e36 100644 --- a/plugins/SpellChecker/src/RichEdit.cpp +++ b/plugins/SpellChecker/src/RichEdit.cpp @@ -296,11 +296,12 @@ int RichEdit::FixSel(CHARRANGE *to_fix, CHARRANGE sel_changed, int new_len) return dif; int newMax = sel_changed.cpMax + dif; + int newMin = sel_changed.cpMin + dif; - if (to_fix->cpMin >= sel_changed.cpMax) + if (to_fix->cpMin >= sel_changed.cpMin) to_fix->cpMin += dif; - else if (to_fix->cpMin >= newMax) // For dif < 0, pos beetween sel_changed.cpMax + dif and sel_changed.cpMax - to_fix->cpMin = newMax; + else if (to_fix->cpMin >= newMin) // For dif < 0, pos beetween sel_changed.cpMax + dif and sel_changed.cpMax + to_fix->cpMin = newMin; if (to_fix->cpMax >= sel_changed.cpMax) to_fix->cpMax += dif; diff --git a/plugins/SpellChecker/src/utils.cpp b/plugins/SpellChecker/src/utils.cpp index a53953991e..e1804a25f7 100644 --- a/plugins/SpellChecker/src/utils.cpp +++ b/plugins/SpellChecker/src/utils.cpp @@ -896,7 +896,7 @@ int AddContactTextBox(MCONTACT hContact, HWND hwnd, char *name, BOOL srmm, HWND dlg->hContact = hContact; dlg->hwnd = hwnd; - strncpy(dlg->name, name, sizeof(dlg->name)); + strncpy(dlg->name, name, _countof(dlg->name)); dlg->enabled = db_get_b(dlg->hContact, MODULE_NAME, dlg->name, 1); dlg->srmm = srmm; @@ -1578,11 +1578,7 @@ BOOL lstreq(TCHAR *a, TCHAR *b, size_t len) { a = CharLower(_tcsdup(a)); b = CharLower(_tcsdup(b)); - BOOL ret; - if (len >= 0) - ret = !_tcsncmp(a, b, len); - else - ret = !mir_tstrcmp(a, b); + BOOL ret = len ? !_tcsncmp(a, b, len) : !mir_tstrcmp(a, b); free(a); free(b); return ret; -- cgit v1.2.3