зеркало из https://github.com/github/codeql.git
C++: Add tests (and fix a missing quote in the alert message).
This commit is contained in:
Родитель
6cb5db2387
Коммит
e1884c193b
|
@ -111,5 +111,5 @@ where
|
|||
uninitialisedBefore(v, f) and
|
||||
useFunc(v, f)
|
||||
select f,
|
||||
"The variable '" + v.getName() +
|
||||
"The variable '" + v.getName() + "'" +
|
||||
" is used in this function but may not be initialized when it is called."
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
| test.cpp:27:5:27:6 | f1 | The variable 'b' is used in this function but may not be initialized when it is called. |
|
|
@ -0,0 +1 @@
|
|||
Critical/GlobalUseBeforeInit.ql
|
|
@ -0,0 +1,38 @@
|
|||
typedef __builtin_va_list va_list;
|
||||
typedef struct {} FILE;
|
||||
|
||||
extern FILE * stdin;
|
||||
extern FILE * stdout;
|
||||
extern FILE * stderr;
|
||||
|
||||
#define va_start(args, fmt) __builtin_va_start(args,fmt)
|
||||
#define va_end(args) __builtin_va_end(args);
|
||||
|
||||
int vfprintf (FILE *, const char *, va_list);
|
||||
|
||||
int a = 1;
|
||||
int b;
|
||||
|
||||
int my_printf(const char * fmt, ...)
|
||||
{
|
||||
va_list vl;
|
||||
int ret;
|
||||
va_start(vl, fmt);
|
||||
ret = vfprintf(stdout, fmt, vl);
|
||||
ret = vfprintf(stderr, fmt, vl);
|
||||
va_end(vl);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int f1()
|
||||
{
|
||||
my_printf("%d\n", a + 2);
|
||||
my_printf("%d\n", b + 2); // BAD
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
int b = f1();
|
||||
return 0;
|
||||
}
|
Загрузка…
Ссылка в новой задаче