From 58951a29a869766e91ca9136168c19833883e093 Mon Sep 17 00:00:00 2001 From: TermiNexus Date: Sat, 10 Oct 2026 22:10:01 +0800 Subject: [PATCH] =?UTF-8?q?fix(narrow):=20File.write=20=E9=95=BF=E5=BA=A6?= =?UTF-8?q?=E5=AE=9E=E5=8F=82=E5=8A=A0=E6=98=BE=E5=BC=8F=20ULONG(...)?= =?UTF-8?q?=EF=BC=88=E9=81=BF=E5=85=8D=2064=E2=86=9232=20=E9=9A=90?= =?UTF-8?q?=E5=BC=8F=E7=AA=84=E5=8C=96=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fileio.File.write(buf, count: ULONG) 的 count 是 32 位,而实参是 sizet/int64(strlen、pos、ir_len、total 等);规则收紧后为隐式窄化,改为显式 ULONG(...)。本文件其它位置无隐式窄化。 --- App/lib/Phase/BuildPipeline.vp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/App/lib/Phase/BuildPipeline.vp b/App/lib/Phase/BuildPipeline.vp index 77a90eb..069abf8 100644 --- a/App/lib/Phase/BuildPipeline.vp +++ b/App/lib/Phase/BuildPipeline.vp @@ -131,7 +131,7 @@ def WriteCallSidecar(temp_dir: str, sha1: str, text: str) -> int: VLogger.error(f"--traceback: failed to write .vpcall (cannot open {vpath}), aborting compilation", "TRACEBACK") stdlib.free(vpath) return 1 - vf.write(text, string.strlen(text)) + vf.write(text, ULONG(string.strlen(text))) vf.close() return _tb_register_vpcall(vpath) @@ -199,7 +199,7 @@ def TranslateFileGetTrans(mb: memhub.MemBuddy*, file_path: str, sha1_val: str, c if pyi_path is not None: pf: fileio.File* = fileio.File(pyi_path, fileio.MODE.W) if not pf.closed: - pf.write(pyi_buf, pyi_pos) + pf.write(pyi_buf, ULONG(pyi_pos)) pf.close() stdlib.free(pyi_path) stdlib.free(pyi_buf) @@ -349,7 +349,7 @@ def write_ir_to_file(ir_buf: bytes, ir_len: sizet, output_dir: str, module_name: f: fileio.File* = fileio.File(path, fileio.MODE.W) if f.closed: return 1 - written: int64 = f.write(ir_buf, ir_len) + written: int64 = f.write(ir_buf, ULONG(ir_len)) f.close() if written < 0: return 1 return 0 @@ -553,9 +553,9 @@ def _phase2_write_cmd(cmd: str) -> None: _phase2_bat_init = 1 hdr1: str = "@echo off\r\n" hdr2: str = "rem TransPyV --phase2command generated commands\r\n" - f.write(hdr1, string.strlen(hdr1)) - f.write(hdr2, string.strlen(hdr2)) - f.write(cmd, string.strlen(cmd)) + f.write(hdr1, ULONG(string.strlen(hdr1))) + f.write(hdr2, ULONG(string.strlen(hdr2))) + f.write(cmd, ULONG(string.strlen(cmd))) f.write("\r\n", 2) f.close() @@ -2358,7 +2358,7 @@ def WriteStackMap(mb: memhub.MemBuddy*, exe_path: str) -> int: if mf.closed: VLogger.error(f"--traceback: failed to write sidecar file (cannot open {map_path}), aborting compilation", "TRACEBACK") return 1 - mf.write(out, total) + mf.write(out, ULONG(total)) mf.close() VLogger.success(f"--traceback: wrote address-to-source-line sidecar {map_path} ({uniq} records, {total} bytes)", "TRACEBACK") return 0