Update cpp/ql/src/Likely Bugs/Memory Management/PointerOverflow.qhelp

Co-Authored-By: Jonas Jensen <jbj@github.com>
This commit is contained in:
Robert Marsh
2019-11-15 10:38:58 -08:00
committed by GitHub
parent 562f62879f
commit 85314c42a9

View File

@@ -22,7 +22,7 @@ To check whether an index <code>i</code> is less than the length of an array,
simply compare these two numbers as unsigned integers: <code>i &lt; ARRAY_LENGTH</code>.
If the length of the array is defined as the difference between two pointers
<code>ptr</code> and <code>p_end</code>, write <code>i &lt; p_end - ptr</code>.
If i is <code>signed</code>, cast it to <code>unsigned</code>
If <code>i</code> is signed, cast it to unsigned
in order to guard against negative <code>i</code>. For example, write
<code>(size_t)i &lt; p_end - ptr</code>.
</p>