diff --git a/php/ext/google/protobuf/def.c b/php/ext/google/protobuf/def.c index 8be2b92c51..ae22338702 100644 --- a/php/ext/google/protobuf/def.c +++ b/php/ext/google/protobuf/def.c @@ -504,13 +504,15 @@ static zend_class_entry *Descriptor_GetGeneratedClass(const upb_MessageDef *m) { zend_string *str = zend_string_init(classname, strlen(classname), 0); zend_class_entry *ce = zend_lookup_class(str); // May autoload the class. + zend_string_release (str); + if (!ce) { char *classname2 = GetPhpClassname(upb_MessageDef_File(m), upb_MessageDef_FullName(m), true); - str = zend_string_init(classname2, strlen(classname2), 0); - ce = zend_lookup_class(str); // May autoload the class. + zend_string *str2 = zend_string_init(classname2, strlen(classname2), 0); + ce = zend_lookup_class(str2); // May autoload the class. - zend_string_release (str); + zend_string_release (str2); free(classname2); if (!ce) {