From 365fb3246bd80780b6315331b9dd5d20bff1f700 Mon Sep 17 00:00:00 2001 From: Takashi Sawanaka Date: Sun, 6 Jan 2019 20:04:30 +0900 Subject: [PATCH] Cppcheck: Either the condition '....empty()' is redundant or content is accessed out of bounds when content is empty. --- Src/LineFiltersList.cpp | 8 ++++---- Src/codepage_detect.cpp | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Src/LineFiltersList.cpp b/Src/LineFiltersList.cpp index 1588d8965..859ffa488 100644 --- a/Src/LineFiltersList.cpp +++ b/Src/LineFiltersList.cpp @@ -224,12 +224,12 @@ void LineFiltersList::SaveFilters() */ void LineFiltersList::Import(const String& filters) { - const TCHAR sep[] = _T("\r\n"); - TCHAR *p_filters = (TCHAR *)&filters[0]; - TCHAR *pfilterNext = nullptr; - if (!filters.empty()) { + const TCHAR sep[] = _T("\r\n"); + TCHAR *p_filters = (TCHAR *)&filters[0]; + TCHAR *pfilterNext = nullptr; + // find each regular expression and add to list TCHAR *token = _tcstok_s(p_filters, sep, &pfilterNext); while (token != nullptr) diff --git a/Src/codepage_detect.cpp b/Src/codepage_detect.cpp index d84439218..2f9c90e62 100644 --- a/Src/codepage_detect.cpp +++ b/Src/codepage_detect.cpp @@ -86,9 +86,9 @@ static unsigned demoGuessEncoding_html(const char *src, size_t len, int defcodep if (!http_equiv.empty() && _stricmp(http_equiv.c_str(), "content-type") == 0) { std::string content(markdown.GetAttribute("content")); - char *pchKey = &content[0]; if (!content.empty()) { + char *pchKey = &content[0]; while (size_t cchKey = strcspn(pchKey += strspn(pchKey, "; \t\r\n"), ";=")) { char *pchValue = pchKey + cchKey; -- 2.11.0