Fix FN for unsigned ptrdiff_t passed as %Ix into scanf

This commit is contained in:
Dmitry-Me 2017-11-08 15:06:51 +03:00
parent 970aee9ce1
commit 89b83b2d16
2 changed files with 2 additions and 3 deletions

View File

@ -763,8 +763,7 @@ void CheckIO::checkFormatString(const Token * const tok,
} else if (specifier.find("I32") != std::string::npos) { } else if (specifier.find("I32") != std::string::npos) {
if (argInfo.typeToken->str() != "int" || argInfo.typeToken->isLong()) if (argInfo.typeToken->str() != "int" || argInfo.typeToken->isLong())
invalidScanfArgTypeError_int(tok, numFormat, specifier, &argInfo, true); invalidScanfArgTypeError_int(tok, numFormat, specifier, &argInfo, true);
} else if (!typesMatch(argInfo.typeToken->originalName(), "ptrdiff_t") && } else if (!typesMatch(argInfo.typeToken->originalName(), "size_t"))
!typesMatch(argInfo.typeToken->originalName(), "size_t"))
invalidScanfArgTypeError_int(tok, numFormat, specifier, &argInfo, true); invalidScanfArgTypeError_int(tok, numFormat, specifier, &argInfo, true);
break; break;
case 'j': case 'j':

View File

@ -1576,7 +1576,7 @@ private:
TEST_SCANF_NOWARN("%Ix", "size_t", "size_t"); TEST_SCANF_NOWARN("%Ix", "size_t", "size_t");
TEST_SCANF_WARN_AKA("%Ix", "size_t", "ssize_t", "signed long", "signed long long"); TEST_SCANF_WARN_AKA("%Ix", "size_t", "ssize_t", "signed long", "signed long long");
TEST_SCANF_WARN_AKA("%Ix", "size_t", "ptrdiff_t", "signed long", "signed long long"); TEST_SCANF_WARN_AKA("%Ix", "size_t", "ptrdiff_t", "signed long", "signed long long");
// TODO TEST_SCANF_WARN_AKA("%Ix", "size_t", "unsigned ptrdiff_t", "unsigned long", "unsigned long long"); TEST_SCANF_WARN_AKA("%Ix", "size_t", "unsigned ptrdiff_t", "unsigned long", "unsigned long long");
TEST_SCANF_WARN_AKA("%Ix", "size_t", "intmax_t", "signed long", "signed long long"); TEST_SCANF_WARN_AKA("%Ix", "size_t", "intmax_t", "signed long", "signed long long");
TEST_SCANF_WARN_AKA("%Ix", "size_t", "uintmax_t", "unsigned long", "unsigned long long"); TEST_SCANF_WARN_AKA("%Ix", "size_t", "uintmax_t", "unsigned long", "unsigned long long");
TEST_SCANF_NOWARN("%Ix", "size_t", "std::size_t"); TEST_SCANF_NOWARN("%Ix", "size_t", "std::size_t");