Skip to content

Commit e99eaeb

Browse files
ihsinmegeoffw0
andauthored
Apply suggestions from code review
Co-authored-by: Geoffrey White <[email protected]>
1 parent a9a2ca3 commit e99eaeb

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

cpp/ql/src/experimental/Security/CWE/CWE-476/DangerousUseOfExceptionBlocks.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
...
22
try {
3-
if (chackValue) throw exception();
3+
if (checkValue) throw exception();
44
valData->bufMyData = new myData*[valData->sizeInt];
55

66
}
@@ -13,7 +13,7 @@ try {
1313
}
1414
...
1515
try {
16-
if (chackValue) throw exception();
16+
if (checkValue) throw exception();
1717
valData->bufMyData = new myData*[valData->sizeInt];
1818

1919
}

cpp/ql/src/experimental/Security/CWE/CWE-476/DangerousUseOfExceptionBlocks.qhelp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"qhelp.dtd">
44
<qhelp>
55
<overview>
6-
<p>When clearing the data in the catch block, you must be sure that the memory was allocated before the exception.</p>
6+
<p>When releasing memory in a catch block, be sure that the memory was allocated and has not already been released.</p>
77

88
</overview>
99

cpp/ql/test/experimental/query-tests/Security/CWE/CWE-476/semmle/tests/test.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ void funcWork3() {
151151

152152
void funcWork4() {
153153
int a;
154-
myGlobalData *valData;
154+
myGlobalData *valData = 0;
155155
try {
156156
valData = new myGlobalData;
157157
cleanFunction();
@@ -167,7 +167,7 @@ void funcWork4() {
167167

168168
void funcWork4b() {
169169
int a;
170-
myGlobalData *valData;
170+
myGlobalData *valData = 0;
171171
try {
172172
valData = new myGlobalData;
173173
cleanFunction();
@@ -181,7 +181,7 @@ void funcWork4b() {
181181
}
182182
void funcWork5() {
183183
int a;
184-
myGlobalData *valData;
184+
myGlobalData *valData = 0;
185185
try {
186186
valData = new myGlobalData;
187187
cleanFunction();
@@ -202,7 +202,7 @@ void funcWork5() {
202202

203203
void funcWork5b() {
204204
int a;
205-
myGlobalData *valData;
205+
myGlobalData *valData = 0;
206206
try {
207207
valData = new myGlobalData;
208208
cleanFunction();
@@ -220,7 +220,7 @@ void funcWork5b() {
220220
void funcWork6() {
221221
int a;
222222
int flagB = 0;
223-
myGlobalData *valData;
223+
myGlobalData *valData = 0;
224224
try {
225225
valData = new myGlobalData;
226226
cleanFunction();

0 commit comments

Comments
 (0)