Skip to content

Commit c8bc1c8

Browse files
authored
Merge pull request #852 from boos/cwe-mapping-16
CWE mapping of accessMoved, accessForwarded, nullPointerArithmeticRedundantCheck, nullPointerArithmetic
2 parents c8a450c + 04f24b4 commit c8bc1c8

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

lib/checknullpointer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ namespace {
3131
}
3232

3333
static const CWE CWE476(476U); // NULL Pointer Dereference
34+
static const CWE CWE682(682U); // Incorrect Calculation
3435

3536
//---------------------------------------------------------------------------
3637

@@ -538,7 +539,7 @@ void CheckNullPointer::arithmeticError(const Token *tok, const ValueFlow::Value
538539
(value && value->condition) ? Severity::warning : Severity::error,
539540
(value && value->condition) ? "nullPointerArithmeticRedundantCheck" : "nullPointerArithmetic",
540541
errmsg,
541-
CWE(0), // unknown - pointer overflow
542+
CWE682, // unknown - pointer overflow
542543
value && value->inconclusive);
543544
}
544545

lib/checkother.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ static const struct CWE CWE561(561U); // Dead Code
4545
static const struct CWE CWE563(563U); // Assignment to Variable without Use ('Unused Variable')
4646
static const struct CWE CWE570(570U); // Expression is Always False
4747
static const struct CWE CWE571(571U); // Expression is Always True
48+
static const struct CWE CWE672(672U); // Operation on a Resource after Expiration or Release
4849
static const struct CWE CWE686(686U); // Function Call With Incorrect Argument Type
4950
static const struct CWE CWE687(687U); // Function Call With Incorrectly Specified Argument Value
5051
static const struct CWE CWE688(688U); // Function Call With Incorrect Variable or Reference as Argument
@@ -2768,6 +2769,6 @@ void CheckOther::accessMovedError(const Token *tok, const std::string &varname,
27682769
return;
27692770
}
27702771
const std::string errmsg(std::string("Access of ") + kindString + " variable " + varname + ".");
2771-
reportError(tok, Severity::warning, errorId, errmsg, CWE(0U), inconclusive);
2772+
reportError(tok, Severity::warning, errorId, errmsg, CWE672, inconclusive);
27722773
}
27732774

0 commit comments

Comments
 (0)