Skip to content

Commit 531c591

Browse files
authored
Update error-alloc-dealloc-mismatch.md
formatting
1 parent 816249d commit 531c591

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

docs/sanitizers/error-alloc-dealloc-mismatch.md

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -19,40 +19,39 @@ The `alloc`/`dealloc` mismatch functionality in AddressSanitizer is off by defau
1919
## Example
2020

2121
```cpp
22-
// alloc-dealloc-mismatch error
22+
// Demonstrate alloc-dealloc-mismatch error
2323
#include <stdio.h>
2424
#include <stdlib.h>
2525

26-
int main(int argc, char* argv[]) {
27-
26+
int main(int argc, char* argv[])
27+
{
2828
if (argc != 2) return -1;
2929

30-
switch (atoi(argv[1])) {
31-
32-
case 1:
33-
delete[](new int[10]);
34-
break;
35-
case 2:
36-
delete (new int[10]); // Boom!
37-
break;
38-
default:
39-
printf("arguments: 1: no error 2: runtime error\n");
40-
return -1;
30+
switch (atoi(argv[1]))
31+
{
32+
case 1:
33+
delete[](new int[10]);
34+
break;
35+
case 2:
36+
delete (new int[10]); // Boom!
37+
break;
38+
default:
39+
printf("arguments: 1: no error 2: runtime error\n");
40+
return -1;
4141
}
42-
4342
return 0;
4443
}
4544
```
4645
47-
To try this example, run the following commands in a Visual Studio 2019 version 16.9 or later [developer command prompt](../build/building-on-the-command-line.md#developer_command_prompt_shortcuts):
46+
Run the following commands in a Visual Studio 2019 version 16.9 or later [developer command prompt](../build/building-on-the-command-line.md#developer_command_prompt_shortcuts) to run the example:
4847
4948
```cmd
5049
cl example1.cpp /fsanitize=address /Zi
5150
set ASAN_OPTIONS=alloc_dealloc_mismatch=1
5251
devenv /debugexe example1.exe 2
5352
```
5453

55-
### Resulting error
54+
### Output
5655

5756
:::image type="content" source="media/alloc-dealloc-mismatch-example-1.png" alt-text="Screenshot of debugger displaying alloc-dealloc-mismatch error in example 1.":::
5857

0 commit comments

Comments
 (0)