mirror of
https://github.com/php/php-src.git
synced 2025-08-15 21:48:51 +02:00
Not all components populate every field in the ExceptInfo structure. Thus we sometimes would try to convert NULL strings and see php_OLECHAR_to_char errors while displaying Exception information. This version is a little smarter about the member derefencing and the resulting error string.
This commit is contained in:
parent
58abda0e58
commit
8ee38d9d75
2 changed files with 40 additions and 16 deletions
|
@ -133,20 +133,32 @@ PHPAPI HRESULT php_COM_invoke(comval *obj, DISPID dispIdMember, WORD wFlags, DIS
|
|||
if (FAILED(hr)) {
|
||||
switch (hr) {
|
||||
case DISP_E_EXCEPTION: {
|
||||
int srclen;
|
||||
char *src = php_OLECHAR_to_char(ExceptInfo.bstrSource, &srclen, codepage TSRMLS_CC);
|
||||
int desclen;
|
||||
char *desc = php_OLECHAR_to_char(ExceptInfo.bstrDescription, &desclen, codepage TSRMLS_CC);
|
||||
int srclen=0;
|
||||
char *src=estrdup("");
|
||||
int desclen=0;
|
||||
char *desc=estrdup("");
|
||||
|
||||
if (ExceptInfo.bstrSource)
|
||||
{
|
||||
src = php_OLECHAR_to_char(ExceptInfo.bstrSource, &srclen, codepage TSRMLS_CC);
|
||||
SysFreeString(ExceptInfo.bstrSource);
|
||||
}
|
||||
if (ExceptInfo.bstrDescription)
|
||||
{
|
||||
desc = php_OLECHAR_to_char(ExceptInfo.bstrDescription, &desclen, codepage TSRMLS_CC);
|
||||
SysFreeString(ExceptInfo.bstrDescription);
|
||||
}
|
||||
|
||||
*ErrString = pemalloc(srclen+desclen+50, 1);
|
||||
sprintf(*ErrString, "<b>Source</b>: %s <b>Description</b>: %s", src, desc);
|
||||
efree(src);
|
||||
efree(desc);
|
||||
SysFreeString(ExceptInfo.bstrSource);
|
||||
SysFreeString(ExceptInfo.bstrDescription);
|
||||
SysFreeString(ExceptInfo.bstrHelpFile);
|
||||
|
||||
if (ExceptInfo.bstrHelpFile)
|
||||
{
|
||||
SysFreeString(ExceptInfo.bstrHelpFile);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DISP_E_PARAMNOTFOUND:
|
||||
case DISP_E_TYPEMISMATCH:
|
||||
*ErrString = pemalloc(25, 1);
|
||||
|
|
|
@ -133,20 +133,32 @@ PHPAPI HRESULT php_COM_invoke(comval *obj, DISPID dispIdMember, WORD wFlags, DIS
|
|||
if (FAILED(hr)) {
|
||||
switch (hr) {
|
||||
case DISP_E_EXCEPTION: {
|
||||
int srclen;
|
||||
char *src = php_OLECHAR_to_char(ExceptInfo.bstrSource, &srclen, codepage TSRMLS_CC);
|
||||
int desclen;
|
||||
char *desc = php_OLECHAR_to_char(ExceptInfo.bstrDescription, &desclen, codepage TSRMLS_CC);
|
||||
int srclen=0;
|
||||
char *src=estrdup("");
|
||||
int desclen=0;
|
||||
char *desc=estrdup("");
|
||||
|
||||
if (ExceptInfo.bstrSource)
|
||||
{
|
||||
src = php_OLECHAR_to_char(ExceptInfo.bstrSource, &srclen, codepage TSRMLS_CC);
|
||||
SysFreeString(ExceptInfo.bstrSource);
|
||||
}
|
||||
if (ExceptInfo.bstrDescription)
|
||||
{
|
||||
desc = php_OLECHAR_to_char(ExceptInfo.bstrDescription, &desclen, codepage TSRMLS_CC);
|
||||
SysFreeString(ExceptInfo.bstrDescription);
|
||||
}
|
||||
|
||||
*ErrString = pemalloc(srclen+desclen+50, 1);
|
||||
sprintf(*ErrString, "<b>Source</b>: %s <b>Description</b>: %s", src, desc);
|
||||
efree(src);
|
||||
efree(desc);
|
||||
SysFreeString(ExceptInfo.bstrSource);
|
||||
SysFreeString(ExceptInfo.bstrDescription);
|
||||
SysFreeString(ExceptInfo.bstrHelpFile);
|
||||
|
||||
if (ExceptInfo.bstrHelpFile)
|
||||
{
|
||||
SysFreeString(ExceptInfo.bstrHelpFile);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case DISP_E_PARAMNOTFOUND:
|
||||
case DISP_E_TYPEMISMATCH:
|
||||
*ErrString = pemalloc(25, 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue