Files
codeql/cpp/ql/src/Critical/GlobalUseBeforeInit.qhelp
2018-08-02 17:53:23 +01:00

31 lines
777 B
XML

<!DOCTYPE qhelp PUBLIC
"-//Semmle//qhelp//EN"
"qhelp.dtd">
<qhelp>
<overview>
<p>This rule finds calls to functions that use a global variable which happen before the variable was initialized.
Not all compilers generate code that zero-out memory, especially when optimizations are enabled or the compiler
is not compliant with the latest language standards. Accessing uninitialized memory will lead to undefined results.
</p>
<include src="dataFlowWarning.qhelp" />
</overview>
<recommendation>
<p>
Initialize the global variable. If no constant can be used for initialization, ensure that all accesses to the variable occur after
the initialization code is executed.
</p>
</recommendation>
<example><sample src="GlobalUseBeforeInit.cpp" />
</example>
</qhelp>