[PATCH 1/4] oledb32/tests: modify size of buffers in order to handle GCC 11.2 warning (GCC11)

Eric Pouech eric.pouech at gmail.com
Sat Oct 2 07:06:18 CDT 2021


in oledb32/tests/convert.c, gcc 11.2 complains (-Warray-bounds)
about accessing fields from a pointer to VARIANT, while underlying storage
buffer is strictly smaller than a VARIANT

gcc doesn't check that accessed field is inside or not the underlying
storage

size of 20 used in most of the tests is not necessarly wrong wrt the
fields adressed, even if I don't fully grasp the logic of a 20 byte buffer:
- VARIANT is 16 bytes on 32bit systems, and 24 bytes on 64 bit systems
- and all the other structures are 16 bytes at most

anyway, make it always of the sizeof of a VARIANT, in order to keep gcc happy

Signed-off-by: Eric Pouech <eric.pouech at gmail.com>

---
 dlls/oledb32/tests/convert.c |   10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/dlls/oledb32/tests/convert.c b/dlls/oledb32/tests/convert.c
index 8ec64d40ae5..1f22851a2b3 100644
--- a/dlls/oledb32/tests/convert.c
+++ b/dlls/oledb32/tests/convert.c
@@ -327,7 +327,7 @@ static void test_converttoi1(void)
 {
     HRESULT hr;
     signed char dst;
-    BYTE src[20];
+    BYTE src[sizeof(VARIANT)]; /* assuming that VARIANT is larger than all the types used in src */
     DBSTATUS dst_status;
     DBLENGTH dst_len;
     static const WCHAR ten[] = {'1','0',0};
@@ -638,7 +638,7 @@ static void test_converttoi2(void)
 {
     HRESULT hr;
     signed short dst;
-    BYTE src[20];
+    BYTE src[sizeof(VARIANT)]; /* assuming that VARIANT is larger than all the types used in src */
     DBSTATUS dst_status;
     DBLENGTH dst_len;
     static const WCHAR ten[] = {'1','0',0};
@@ -950,7 +950,7 @@ static void test_converttoi4(void)
 {
     HRESULT hr;
     INT i4;
-    BYTE src[20];
+    BYTE src[sizeof(VARIANT)];  /* assuming that VARIANT is larger than all the types used in src */
     DBSTATUS dst_status;
     DBLENGTH dst_len;
     static const WCHAR ten[] = {'1','0',0};
@@ -1224,7 +1224,7 @@ static void test_converttoi8(void)
 {
     HRESULT hr;
     LARGE_INTEGER dst;
-    BYTE src[20];
+    BYTE src[sizeof(VARIANT)];  /* assuming that VARIANT is larger than all the types used in src */
     DBSTATUS dst_status;
     DBLENGTH dst_len;
     static const WCHAR ten[] = {'1','0',0};
@@ -2774,7 +2774,7 @@ static void test_converttoui4(void)
 {
     HRESULT hr;
     DWORD dst;
-    BYTE src[20];
+    BYTE src[sizeof(VARIANT)];
     DBSTATUS dst_status;
     DBLENGTH dst_len;
 




More information about the wine-devel mailing list