fix(structgen): lookup_field SHA1 隔离临时缓冲改用 stdlib.malloc(lookup_field 无 pool 参数)并补 free

This commit is contained in:
TermiNexus committed 2026-08-26 23:54:22 +08:00
1 parent ad1089d9af
commit cc9112b54a
1 file changed
+5 -1
+5 -1
View File
@@ -722,7 +722,7 @@ class StructGenMixin:
pre_len_lf: t.CSizeT = t.CSizeT(
t.CUInt64T(dot_ty_lf) - t.CUInt64T(ty_name))
if pre_len_lf == 16:
sha_buf_lf: str = pool.alloc(17)
sha_buf_lf: str = stdlib.malloc(17)
if sha_buf_lf is not None:
string.strncpy(sha_buf_lf, ty_name, 16)
sha_buf_lf[16] = '\0'
@@ -746,9 +746,13 @@ class StructGenMixin:
fe: GenTypes.FieldEntry | t.CPtr = self._get_field_entry(entry, fi)
if fe is not None and fe.Name is not None:
if string.strcmp(fe.Name, field_name) == 0:
if ty_sha1_lf is not None:
stdlib.free(ty_sha1_lf)
return fe
# 名称匹配但字段未找到,继续检查其他同名 entry(跨模块同名)
continue
if ty_sha1_lf is not None:
stdlib.free(ty_sha1_lf)
# 所有条目都未匹配
return None