Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d693eb8

Browse files
committed
CPP: Correct the ConditionallyUninitializedVariable examples.
1 parent f1004b1 commit d693eb8

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

cpp/ql/src/Security/CWE/CWE-457/ConditionallyUninitializedVariableBad.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ int notify(int deviceNumber) {
1919
DeviceConfig config;
2020
initDeviceConfig(&config, deviceNumber);
2121
// BAD: Using config without checking the status code that is returned
22-
if (config->isEnabled) {
23-
notifyChannel(config->channel);
22+
if (config.isEnabled) {
23+
notifyChannel(config.channel);
2424
}
25-
}
25+
}

cpp/ql/src/Security/CWE/CWE-457/ConditionallyUninitializedVariableGood.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ void notify(int deviceNumber) {
2020
int statusCode = initDeviceConfig(&config, deviceNumber);
2121
if (statusCode == 0) {
2222
// GOOD: Status code returned by initialization function is checked, so this is safe
23-
if (config->isEnabled) {
24-
notifyChannel(config->channel);
23+
if (config.isEnabled) {
24+
notifyChannel(config.channel);
2525
}
2626
}
27-
}
27+
}

0 commit comments

Comments
 (0)