Skip to content
This repository was archived by the owner on Jan 5, 2023. It is now read-only.

Commit 699208a

Browse files
authored
Merge pull request #102 from marcogario/integeroverflow_qhelp
Integeroverflow.qhelp: use paragraphs within sections
2 parents d452fc0 + 14e4e2d commit 699208a

1 file changed

Lines changed: 25 additions & 17 deletions

File tree

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,31 @@
11
<!DOCTYPE qhelp SYSTEM "qhelp.dtd">
22
<qhelp>
3-
<overview>
4-
Arithmetic calculations involving integers should be checked to ensure that overflow or
5-
underflow cannot occur, as this may cause incorrect results or program crashes.
6-
</overview>
7-
<recommendation>
3+
<overview>
4+
<p>
5+
Arithmetic calculations involving integers should be checked to ensure that overflow or
6+
underflow cannot occur, as this may cause incorrect results or program crashes.
7+
</p>
8+
</overview>
9+
<recommendation>
10+
<p>
811
Before performing an integer operation that may cause an overflow, check the operands to ensure
912
that the result of the operation will fit into the value range of the type. Alternatively, check
1013
the result of the operation to see whether it overflowed.
11-
</recommendation>
12-
<example>
13-
In the following example snippet, the addition <code>start + offset</code> may overflow if
14-
either <code>start</code> or <code>offset</code> is very large, which will cause the indexing
15-
operation to panic at runtime:
16-
<sample src="IntegerOverflow.go" />
17-
One way to prevent this is to check whether <code>start + offset</code> overflows:
18-
<sample src="IntegerOverflowGood.go" />
19-
</example>
20-
<references>
21-
<li>Wikipedia <a href="https://en.wikipedia.org/wiki/Integer_overflow">Integer overflow</a>.</li>
22-
</references>
14+
</p>
15+
</recommendation>
16+
<example>
17+
<p>
18+
In the following example snippet, the addition <code>start + offset</code> may overflow if
19+
either <code>start</code> or <code>offset</code> is very large, which will cause the indexing
20+
operation to panic at runtime:
21+
</p>
22+
<sample src="IntegerOverflow.go" />
23+
<p>
24+
One way to prevent this is to check whether <code>start + offset</code> overflows:
25+
</p>
26+
<sample src="IntegerOverflowGood.go" />
27+
</example>
28+
<references>
29+
<li>Wikipedia <a href="https://en.wikipedia.org/wiki/Integer_overflow">Integer overflow</a>.</li>
30+
</references>
2331
</qhelp>

0 commit comments

Comments
 (0)