Skip to content

Commit fe3f776

Browse files
Merge pull request #5151 from MicrosoftDocs/main638725626269053236sync_temp
For protected branch, push strategy should use PR and merge to target branch method to work around git push error
2 parents 67585a2 + 68b5ba1 commit fe3f776

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

docs/code-quality/c33001.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,23 @@ helpviewer_keywords: ["C33001"]
1313
1414
## Remarks
1515

16-
This warning is triggered when an uninitialized `VARIANT` is passed to an API such as `VariantClear`
17-
that expects an initialized `VARIANT`.
16+
This warning is triggered when an uninitialized `VARIANT` is passed to an API, such as `VariantClear`, that clears the object. Initialize the `VARIANT` before passing it to these functions so it can be properly cleared.
17+
18+
This warning applies to these functions:
19+
20+
* `VariantClear`
21+
* `PropVariantClear`
22+
* `VariantCopy`
23+
* `VariantCopyInd`
24+
* `VariantChangeType`
25+
* `VariantChangeTypeEx`
26+
* `DestroyPropVariant`
1827

1928
Code analysis name: `VARIANTCLEAR_UNINITIALIZED`
2029

2130
## Example
2231

23-
The following sample code causes warning C33001:
32+
The following code causes warning C33001:
2433

2534
```cpp
2635
#include <Windows.h>
@@ -36,11 +45,11 @@ HRESULT foo(bool some_condition)
3645
//...
3746
}
3847

39-
VariantClear(&var); // C33001
48+
VariantClear(&var); // C33001
4049
}
4150
```
4251
43-
These warnings are corrected by ensuring `VariantClear` is called only for a properly initialized `VARIANT`:
52+
In this example, the warning is corrected by calling `VariantClear` only after `var` has been initialized:
4453
4554
```cpp
4655
#include <Windows.h>
@@ -54,12 +63,12 @@ HRESULT foo(bool some_condition)
5463
//...
5564
VariantInit(&var);
5665
//...
57-
VariantClear(&var); // C33001
66+
VariantClear(&var); // OK
5867
}
5968
}
6069
```
6170

6271
## See also
6372

64-
[C33004](./c33004.md)
73+
[C33004](./c33004.md)\
6574
[C33005](./c33005.md)

0 commit comments

Comments
 (0)