CWE 546
R2026bDescription
Suspicious Comment
Polyspace Implementation
Polyspace® checks for the issue Suspicious Comments
Examples
The issue occurs when a comment in your code contains one of these suspicious words:
BUGHACKFIXMELATERTODO
The matching is case-insensitive. The checker also detects these words when they are
prefixed by a symbol such as @, or when they are followed by numbers or
a trailing special character. For instance, @TODO,
FIXME21, and todo: all trigger a violation.
A function or variable name that contains one of these words does not trigger a violation. The rule checker only flags comments.
Comments containing these words suggest that the code has known problems or unfinished functionality that a developer intended to address later. Shipping code with these markers can indicate missing security checks, incomplete error handling, or unresolved defects. An attacker who gains access to the source code can use these markers to identify weak points.
Resolve the underlying issue described in the comment and remove the suspicious comments. If the comment describes work that is genuinely deferred, track it in an issue tracker and remove the comment from the code.
In this example, Polyspace detects comments that contain suspicious words indicating incomplete or problematic code.
#include <stdlib.h>
void process_data(int *data, int count) {
/* HACK: skipping validation for now */ // Noncompliant
for (int i = 0; i < count; i++) {
data[i] = data[i] * 2;
}
}
void initialize_buffer(char *buffer, int size) {
// TODO: add bounds checking // Noncompliant
for (int i = 0; i < size; i++) {
buffer[i] = 0;
}
}Resolve the issues described in the suspicious comments and remove the markers.
#include <stdlib.h>
void process_data(int *data, int count) {
/* Input is validated by the caller per API contract */ // Compliant
for (int i = 0; i < count; i++) {
data[i] = data[i] * 2;
}
}
void initialize_buffer(char *buffer, int size) {
if (buffer == NULL || size <= 0) { // Compliant
return;
}
for (int i = 0; i < size; i++) {
buffer[i] = 0;
}
}Track the issues in an issue tracker and remove the comments.
#include <stdlib.h>
void process_data(int *data, int count) {
/* JIRA 12345*/
for (int i = 0; i < count; i++) {
data[i] = data[i] * 2;
}
}
void initialize_buffer(char *buffer, int size) {
// Jira 78942
for (int i = 0; i < size; i++) {
buffer[i] = 0;
}
}Check Information
| Group: Bad Coding Practices |
PQL Name:
std.cwe_native.R546 |
Version History
Introduced in R2026b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)