From ecd1476f4ae7499f906c1aef082b95cac79a0cd4 Mon Sep 17 00:00:00 2001 From: Brent Shaffer Date: Mon, 6 Jun 2022 18:36:26 +0000 Subject: [PATCH] fix valgrind error --- php/ext/google/protobuf/def.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) 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) {