COM: Fix filling arrays with more than 4G cells

Signed-off-by: Simon Rozman <simon@rozman.si>
This commit is contained in:
Simon Rozman 2025-03-28 10:08:36 +01:00
parent 901b5af311
commit 0f412d5c38

View File

@ -10,9 +10,10 @@
#include "Common.h"
#include <assert.h>
#include <unknwn.h>
#include <intsafe.h>
#include <stdexcept>
#include <string>
#include <unknwn.h>
namespace winstd
{
@ -1507,7 +1508,9 @@ namespace winstd
///
inline _Ret_notnull_ LPSAFEARRAY BuildSAFEARRAY(_In_ VARTYPE vt, _In_opt_ LPCVOID array, _In_ ULONG columns, _In_ ULONG rows)
{
const size_t n = columns * rows;
SIZE_T n;
if (FAILED(SIZETMult(columns, rows, &n)))
throw std::invalid_argument("array is too big");
if (!array && n)
throw std::invalid_argument("array is NULL");
@ -1559,7 +1562,9 @@ namespace winstd
///
inline VARIANT BuildVBARRAY(_In_ VARTYPE vt, _In_opt_ LPCVOID array, _In_ ULONG columns, _In_ ULONG rows)
{
const size_t n = columns * rows;
SIZE_T n;
if (FAILED(SIZETMult(columns, rows, &n)))
throw std::invalid_argument("array is too big");
if (!array && n)
throw std::invalid_argument("array is NULL");