@@ -184,23 +184,15 @@ PHP_COM_DOTNET_API int php_com_import_typelib(ITypeLib *TL, int mode, int codepa
184
184
}
185
185
186
186
const_name = php_com_olestring_to_string (bstr_ids , & len , codepage );
187
- c .name = zend_string_init (const_name , len , mode & CONST_PERSISTENT );
188
- // TODO: avoid reallocation???
189
- efree (const_name );
190
- if (c .name == NULL ) {
191
- ITypeInfo_ReleaseVarDesc (TypeInfo , pVarDesc );
192
- continue ;
193
- }
194
- //??? c.name_len++; /* include NUL */
195
187
SysFreeString (bstr_ids );
196
188
197
189
/* sanity check for the case where the constant is already defined */
198
190
php_com_zval_from_variant (& value , pVarDesc -> lpvarValue , codepage );
199
- if ((exists = zend_get_constant ( c . name )) != NULL ) {
191
+ if ((exists = zend_get_constant_str ( const_name , len )) != NULL ) {
200
192
if (COMG (autoreg_verbose ) && !compare_function (& results , & value , exists )) {
201
- php_error_docref (NULL , E_WARNING , "Type library constant %s is already defined" , ZSTR_VAL ( c . name ) );
193
+ php_error_docref (NULL , E_WARNING , "Type library constant %s is already defined" , const_name );
202
194
}
203
- zend_string_release_ex ( c . name , mode & CONST_PERSISTENT );
195
+ efree ( const_name );
204
196
ITypeInfo_ReleaseVarDesc (TypeInfo , pVarDesc );
205
197
continue ;
206
198
}
@@ -209,6 +201,8 @@ PHP_COM_DOTNET_API int php_com_import_typelib(ITypeLib *TL, int mode, int codepa
209
201
if (Z_TYPE (value ) == IS_LONG ) {
210
202
ZEND_CONSTANT_SET_FLAGS (& c , mode , 0 );
211
203
ZVAL_LONG (& c .value , Z_LVAL (value ));
204
+ c .name = zend_string_init (const_name , len , mode & CONST_PERSISTENT );
205
+ efree (const_name );
212
206
zend_register_constant (& c );
213
207
}
214
208
ITypeInfo_ReleaseVarDesc (TypeInfo , pVarDesc );
0 commit comments