CWE-482 — Comparing instead of Assigning
CWE-482: Comparing instead of Assigning
MITRE CWE weakness
| Kind | Weakness |
| Abstraction | Variant |
| Status | Draft |
| Likelihood of exploit | Low |
Description
The code uses an operator for comparison when the intention was to perform an assignment.
In many languages, the compare statement is very close in appearance to the assignment statement; they are often confused.
Common consequences
- Availability, Integrity: Unexpected State
Mitigations
Testing — Many IDEs and static analysis products will detect this problem.
References
- CWE page: https://cwe.mitre.org/data/definitions/482.html
- CWE list: https://cwe.mitre.org/data/index.html