fix valgrind

pull/10041/head
Brent Shaffer 2 years ago
parent 0b90ee8d3f
commit 4f28c5ab4e
  1. 6
      php/ext/google/protobuf/names.c
  2. 2
      php/ext/google/protobuf/protobuf.c

@ -275,10 +275,8 @@ bool IsPreviouslyUnreservedClassName(const char* fullname) {
}
classname += 2;
int length = strlen(classname);
char* lower =strdup_nolocale_lower(classname, length);
int j;
for (j = 0; kPreviouslyUnreservedNames[j]; j++) {
char* lower = strdup_nolocale_lower(classname, length);
for (int j = 0; kPreviouslyUnreservedNames[j]; j++) {
if (strcmp(kPreviouslyUnreservedNames[j], lower) == 0) {
free(lower);
return true;

@ -246,8 +246,10 @@ void NameMap_AddMessage(const upb_MessageDef *m) {
char *k = GetPhpClassname(upb_MessageDef_File(m), upb_MessageDef_FullName(m), (bool)i);
zend_hash_str_add_ptr(&PROTOBUF_G(name_msg_cache), k, strlen(k), (void*)m);
if (!IsPreviouslyUnreservedClassName(k)) {
free(k);
return;
}
free(k);
}
}

Loading…
Cancel
Save