|
1 | | - <!DOCTYPE qhelp PUBLIC |
2 | | - "-//Semmle//qhelp//EN" |
3 | | - "qhelp.dtd"> |
4 | | - <qhelp> |
5 | | - <overview> |
6 | | - <p>Different overloads of the <code>new</code> operator handle allocation failures in different ways. |
7 | | - If <code>new T</code> fails for some type <code>T</code>, it throws a <code>std::bad_alloc</code> exception, |
8 | | - but <code>new(std::nothrow) T</code> returns a null pointer. If the programmer does not use the corresponding |
9 | | - method of error handling, allocation failure may go unhandled and could cause the program to behave in |
10 | | - unexpected ways.</p> |
| 1 | +<!DOCTYPE qhelp PUBLIC |
| 2 | + "-//Semmle//qhelp//EN" |
| 3 | + "qhelp.dtd"> |
| 4 | +<qhelp> |
| 5 | +<overview> |
| 6 | +<p>Different overloads of the <code>new</code> operator handle allocation failures in different ways. |
| 7 | +If <code>new T</code> fails for some type <code>T</code>, it throws a <code>std::bad_alloc</code> exception, |
| 8 | +but <code>new(std::nothrow) T</code> returns a null pointer. If the programmer does not use the corresponding |
| 9 | +method of error handling, allocation failure may go unhandled and could cause the program to behave in |
| 10 | +unexpected ways.</p> |
11 | 11 |
|
12 | | - </overview> |
13 | | - <recommendation> |
| 12 | +</overview> |
| 13 | +<recommendation> |
14 | 14 |
|
15 | | - <p>Make sure that exceptions are handled appropriately if <code>new T</code> is used. On the other hand, |
16 | | - make sure to handle the possibility of null pointers if <code>new(std::nothrow) T</code> is used.</p> |
| 15 | +<p>Make sure that exceptions are handled appropriately if <code>new T</code> is used. On the other hand, |
| 16 | +make sure to handle the possibility of null pointers if <code>new(std::nothrow) T</code> is used.</p> |
17 | 17 |
|
18 | | - </recommendation> |
19 | | - <example> |
20 | | - <sample src="IncorrectAllocationErrorHandling.cpp" /> |
| 18 | +</recommendation> |
| 19 | +<example> |
| 20 | +<sample src="IncorrectAllocationErrorHandling.cpp" /> |
21 | 21 |
|
22 | | - </example> |
23 | | - <references> |
| 22 | +</example> |
| 23 | +<references> |
24 | 24 |
|
25 | | - <li> |
26 | | - CERT C++ Coding Standard: |
27 | | - <a href="https://wiki.sei.cmu.edu/confluence/display/cplusplus/MEM52-CPP.+Detect+and+handle+memory+allocation+errors">MEM52-CPP. Detect and handle memory allocation errors</a>. |
28 | | - </li> |
| 25 | +<li> |
| 26 | + CERT C++ Coding Standard: |
| 27 | +<a href="https://wiki.sei.cmu.edu/confluence/display/cplusplus/MEM52-CPP.+Detect+and+handle+memory+allocation+errors">MEM52-CPP. Detect and handle memory allocation errors</a>. |
| 28 | +</li> |
29 | 29 |
|
30 | | - </references> |
31 | | - </qhelp> |
| 30 | +</references> |
| 31 | +</qhelp> |
0 commit comments