Skip to content

Commit ff3430d

Browse files
committed
Use '// GOOD' and '// BAD' annotations for query diagnostics.
1 parent 566fdc3 commit ff3430d

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

cpp/ql/test/query-tests/Likely Bugs/Memory Management/AllocaInLoop/AllocaInLoop1.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void foo(const struct vtype* vec, int count) {
2828
b1 = new char[w1];
2929
} else {
3030
// Allocate the buffer on stack
31-
b1 = (char*) alloca(w1); // [FLAG]
31+
b1 = (char*) alloca(w1); // BAD
3232
}
3333
}
3434
memcpy(b1, v, w1);
@@ -52,7 +52,7 @@ void bar(const struct vtype* vec, int count) {
5252
b1 = new char[w1];
5353
} else {
5454
// Allocate the buffer on stack
55-
b1 = (char*) alloca(w1); // [FLAG]
55+
b1 = (char*) alloca(w1); // BAD
5656
}
5757
}
5858
} while (0);
@@ -77,7 +77,7 @@ void baz(const struct vtype* vec, int count) {
7777
b1 = new char[w1];
7878
} else {
7979
// Allocate the buffer on stack
80-
b1 = (char*) alloca(w1); // [FLAG]
80+
b1 = (char*) alloca(w1); // BAD
8181
}
8282
}
8383
memcpy(b1, v, w1);

cpp/ql/test/query-tests/Likely Bugs/Memory Management/AllocaInLoop/AllocaInLoop1ms.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ void foo(const struct vtype* vec, int count) {
2525
b1 = new char[w1];
2626
} else {
2727
// Allocate the buffer on stack
28-
b1 = (char*) _alloca(w1); // [FLAG]
28+
b1 = (char*) _alloca(w1); // BAD
2929
}
3030
}
3131
memcpy(b1, v, w1);
@@ -49,7 +49,7 @@ void bar(const struct vtype* vec, int count) {
4949
b1 = new char[w1];
5050
} else {
5151
// Allocate the buffer on stack
52-
b1 = (char*) _malloca(w1); // [FLAG]
52+
b1 = (char*) _malloca(w1); // BAD
5353
}
5454
}
5555
} while (0);
@@ -76,7 +76,7 @@ void baz(const struct vtype* vec, int count) {
7676
b1 = new char[w1];
7777
} else {
7878
// Allocate the buffer on stack
79-
b1 = (char*) _alloca(w1); // [FLAG]
79+
b1 = (char*) _alloca(w1); // BAD
8080
}
8181
}
8282
memcpy(b1, v, w1);

cpp/ql/test/query-tests/Likely Bugs/Memory Management/AllocaInLoop/AllocaInLoop2.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ void foo(const struct vtype* vec, int count) {
3636
b1 = (char *)malloc(w1);
3737
} else {
3838
// Allocate the buffer on stack
39-
b1 = (char*) alloca(w1); // [FLAG]
39+
b1 = (char*) alloca(w1); // BAD
4040
iter = 1;
4141
}
4242
}
@@ -61,7 +61,7 @@ void bar(const struct vtype* vec, int count) {
6161
b1 = (char *)malloc(w1);
6262
} else {
6363
// Allocate the buffer on stack
64-
b1 = (char*) alloca(w1); // [DO NOT FLAG]
64+
b1 = (char*) alloca(w1); // GOOD
6565
}
6666
}
6767
} while (0);
@@ -76,7 +76,7 @@ void bar(const struct vtype* vec, int count) {
7676
// case 3: alloca called outside any loops
7777
void baz(int count) {
7878

79-
char *buf = (char *)alloca(32); // [DO NOT FLAG]
79+
char *buf = (char *)alloca(32); // GOOD
8080
sprintf(buf, "Value is %d\n", count);
8181
printf("%s", buf);
8282
}
@@ -94,7 +94,7 @@ void foo_ms(const struct vtype* vec, int count) {
9494
(char *)malloc(w1);
9595
} else {
9696
// Allocate the buffer on stack
97-
b1 = (char*) _alloca(w1); // [DO NOT FLAG]
97+
b1 = (char*) _alloca(w1); // GOOD
9898
}
9999
}
100100
memcpy(b1, v, w1);
@@ -118,7 +118,7 @@ void bar_ms(const struct vtype* vec, int count) {
118118
b1 = (char *)malloc(w1);
119119
} else {
120120
// Allocate the buffer on stack
121-
b1 = (char*) _malloca(w1); // [DO NOT FLAG]
121+
b1 = (char*) _malloca(w1); // GOOD
122122
}
123123
}
124124
} while (0);
@@ -145,7 +145,7 @@ void baz_ms(const struct vtype* vec, int count) {
145145
b1 = (char *)malloc(w1);
146146
} else {
147147
// Allocate the buffer on stack
148-
b1 = (char*) _alloca(w1); // [DO NOT FLAG]
148+
b1 = (char*) _alloca(w1); // GOOD
149149
}
150150
}
151151
memcpy(b1, v, w1);

cpp/ql/test/query-tests/Likely Bugs/Memory Management/AllocaInLoop/AllocaInLoop3.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ void *__builtin_alloca(int sz);
1515
// case 1: a GNU c/c++ lambda with an alloca in it
1616
char *foo(int count) {
1717
char *buf = ({
18-
char *b = (char *)alloca(32); // [DO NOT FLAG]
18+
char *b = (char *)alloca(32); // GOOD
1919
sprintf(b, "Value is %d\n", count);
2020
b;
2121
});
@@ -28,7 +28,7 @@ char *bar(int count) {
2828
char *buf;
2929
do {
3030
buf = ({
31-
char *b = (char *)alloca(32); // [DO NOT FLAG]
31+
char *b = (char *)alloca(32); // GOOD
3232
sprintf(b, "Value is %d\n", count);
3333
b;
3434
});
@@ -42,7 +42,7 @@ char *baz(int count) {
4242
char *buf;
4343
do {
4444
buf = ({
45-
char *b = (char *)alloca(32); // [FLAG]
45+
char *b = (char *)alloca(32); // BAD
4646
sprintf(b, "Value is %d\n", count);
4747
b;
4848
});

0 commit comments

Comments
 (0)