mirror of
https://github.com/github/codeql.git
synced 2026-01-27 13:23:00 +01:00
41 lines
1.0 KiB
XML
41 lines
1.0 KiB
XML
<!DOCTYPE qhelp PUBLIC
|
|
"-//Semmle//qhelp//EN"
|
|
"qhelp.dtd">
|
|
<qhelp>
|
|
<overview>
|
|
<p>
|
|
Integer literals starting with the digit <code>0</code> may be interpreted as octal numbers by some platforms
|
|
but not others, and thus should be avoided. This does not make a difference for the literal <code>0</code>
|
|
itself.
|
|
</p>
|
|
|
|
</overview>
|
|
<recommendation>
|
|
|
|
<p>
|
|
If the literal was meant to be octal, convert it to a decimal or hexadecimal number. Otherwise, remove
|
|
the leading zero.
|
|
</p>
|
|
|
|
</recommendation>
|
|
<example>
|
|
|
|
<p>
|
|
The following example uses the literal <code>012</code>, which some platforms will interpret as an octal
|
|
encoding of the decimal number <code>10</code>, while others will interpret it as the decimal number
|
|
<code>12</code>. Depending on the desired interpretation, it should be replaced with either <code>10</code>
|
|
or <code>12</code>.
|
|
</p>
|
|
|
|
<sample src="examples/OctalLiteral.js" />
|
|
|
|
</example>
|
|
<references>
|
|
|
|
|
|
<li>Ecma International, <i>ECMAScript Language Definition</i>, 5.1 Edition, Annex B.1.1. ECMA, 2011.</li>
|
|
|
|
|
|
</references>
|
|
</qhelp>
|