diff options
author | Anatol Belski <ab@php.net> | 2014-10-28 17:23:40 +0100 |
---|---|---|
committer | Anatol Belski <ab@php.net> | 2014-10-28 17:25:09 +0100 |
commit | efe9cc3a86a769f1ac3d16f4b12f5e83053c6822 (patch) | |
tree | 4b3720699093345e776c05eb1b3ba0fc8e1adb2e | |
parent | 05fa1b8ecc025335cef3bd3e22ba94bf9d0632fa (diff) | |
download | php-git-efe9cc3a86a769f1ac3d16f4b12f5e83053c6822.tar.gz |
rework fix to php_com_do_invoke_byref,
fix crashing function with void arguments
-rw-r--r-- | ext/com_dotnet/com_com.c | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/ext/com_dotnet/com_com.c b/ext/com_dotnet/com_com.c index 6328a6b090..e1a9503dff 100644 --- a/ext/com_dotnet/com_com.c +++ b/ext/com_dotnet/com_com.c @@ -474,7 +474,7 @@ int php_com_do_invoke_byref(php_com_dotnet_object *obj, zend_internal_function * int i, byref_count = 0, j; /* assumption: that the active function (f) is the function we generated for the engine */ - if (!f || f->arg_info == NULL) { + if (!f) { return FAILURE; } @@ -496,7 +496,7 @@ int php_com_do_invoke_byref(php_com_dotnet_object *obj, zend_internal_function * vargs = (VARIANT*)safe_emalloc(sizeof(VARIANT), nargs, 0); } - if (f) { + if (f->arg_info) { for (i = 0; i < nargs; i++) { if (f->arg_info[nargs - i - 1].pass_by_reference) { byref_count++; @@ -551,30 +551,36 @@ int php_com_do_invoke_byref(php_com_dotnet_object *obj, zend_internal_function * /* release variants */ if (vargs) { - for (i = 0, j = 0; i < nargs; i++) { - /* if this was byref, update the zval */ - if (f && f->arg_info[nargs - i - 1].pass_by_reference) { - SEPARATE_ZVAL_IF_NOT_REF(&args[nargs - i - 1]); - - /* if the variant is pointing at the byref_vals, we need to map - * the pointee value as a zval; otherwise, the value is pointing - * into an existing PHP variant record */ - if (V_VT(&vargs[i]) & VT_BYREF) { - if (vargs[i].byref == &V_UINT(&byref_vals[j])) { - /* copy that value */ - php_com_zval_from_variant(&args[nargs - i - 1], &byref_vals[j], + if (f && f->arg_info) { + for (i = 0, j = 0; i < nargs; i++) { + /* if this was byref, update the zval */ + if (f->arg_info[nargs - i - 1].pass_by_reference) { + SEPARATE_ZVAL_IF_NOT_REF(&args[nargs - i - 1]); + + /* if the variant is pointing at the byref_vals, we need to map + * the pointee value as a zval; otherwise, the value is pointing + * into an existing PHP variant record */ + if (V_VT(&vargs[i]) & VT_BYREF) { + if (vargs[i].byref == &V_UINT(&byref_vals[j])) { + /* copy that value */ + php_com_zval_from_variant(&args[nargs - i - 1], &byref_vals[j], + obj->code_page TSRMLS_CC); + } + } else { + /* not sure if this can ever happen; the variant we marked as BYREF + * is no longer BYREF - copy its value */ + php_com_zval_from_variant(&args[nargs - i - 1], &vargs[i], obj->code_page TSRMLS_CC); } - } else { - /* not sure if this can ever happen; the variant we marked as BYREF - * is no longer BYREF - copy its value */ - php_com_zval_from_variant(&args[nargs - i - 1], &vargs[i], - obj->code_page TSRMLS_CC); + VariantClear(&byref_vals[j]); + j++; } - VariantClear(&byref_vals[j]); - j++; - } - VariantClear(&vargs[i]); + VariantClear(&vargs[i]); + } + } else { + for (i = 0, j = 0; i < nargs; i++) { + VariantClear(&vargs[i]); + } } efree(vargs); } |