Skip to content

Commit c865472

Browse files
committed
fix datatype mismatches, remove dead part of code
1 parent cf979ca commit c865472

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

ext/com_dotnet/com_typeinfo.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib(char *search_string, int codep
7171
if (FAILED(hr) && (major == NULL || minor == NULL)) {
7272
IDispatch *disp = NULL;
7373
ITypeInfo *info = NULL;
74-
int idx;
74+
UINT idx;
7575

7676
if (SUCCEEDED(hr = CoCreateInstance(&clsid, NULL, CLSCTX_SERVER, &IID_IDispatch, (LPVOID*)&disp)) &&
7777
SUCCEEDED(hr = IDispatch_GetTypeInfo(disp, 0, LANG_NEUTRAL, &info))) {
@@ -96,7 +96,7 @@ PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib(char *search_string, int codep
9696
DWORD VersionCount;
9797
char version[20];
9898
char *libname;
99-
DWORD libnamelen;
99+
long libnamelen;
100100

101101
if (ERROR_SUCCESS == RegOpenKeyEx(HKEY_CLASSES_ROOT, "TypeLib", 0, KEY_READ, &hkey) &&
102102
ERROR_SUCCESS == RegQueryInfoKey(hkey, NULL, NULL, NULL, &SubKeys,
@@ -116,7 +116,7 @@ PHP_COM_DOTNET_API ITypeLib *php_com_load_typelib(char *search_string, int codep
116116
continue;
117117
}
118118
/* get the default value for this key and compare */
119-
libnamelen = (DWORD)strlen(search_string)+1;
119+
libnamelen = (long)strlen(search_string)+1;
120120
if (ERROR_SUCCESS == RegQueryValue(hsubkey, version, libname, &libnamelen)) {
121121
if (0 == stricmp(libname, search_string)) {
122122
char *str = NULL;

ext/com_dotnet/com_variant.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ static void safe_array_from_zval(VARIANT *v, zval *z, int codepage TSRMLS_DC)
3939
HashPosition pos;
4040
int keytype;
4141
zend_string *strindex;
42-
zend_long intindex = -1;
43-
zend_long max_index = 0;
42+
zend_ulong intindex = 0;
4443
VARIANT *va;
4544
zval *item;
4645

@@ -54,15 +53,15 @@ static void safe_array_from_zval(VARIANT *v, zval *z, int codepage TSRMLS_DC)
5453
goto bogus;
5554
} else if (HASH_KEY_NON_EXISTENT == keytype) {
5655
break;
57-
}
58-
if (intindex > max_index) {
59-
max_index = intindex;
56+
} else if (intindex > UINT_MAX) {
57+
php_error_docref(NULL TSRMLS_CC, E_WARNING, "COM: max number %u of elements in safe array exceeded", UINT_MAX);
58+
break;
6059
}
6160
}
6261

6362
/* allocate the structure */
6463
bound.lLbound = 0;
65-
bound.cElements = (ULONG)(intindex + 1);
64+
bound.cElements = zend_hash_num_elements(HASH_OF(z));
6665
sa = SafeArrayCreate(VT_VARIANT, 1, &bound);
6766

6867
/* get a lock on the array itself */

0 commit comments

Comments
 (0)