From 2de76ae94dea45ca07f5548353740a104df40af7 Mon Sep 17 00:00:00 2001 From: Rot127 <45763064+Rot127@users.noreply.github.com> Date: Thu, 14 May 2026 10:23:59 +0000 Subject: [PATCH] cs_disasm_iter: return early on zero-size input (#2886) (#2920) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prevent calling backend decoder with no remaining bytes, which could lead to out-of-bounds reads. Co-authored-by: Petar Andrić --- cs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cs.c b/cs.c index eefba1435..a70c9e8a5 100644 --- a/cs.c +++ b/cs.c @@ -1114,6 +1114,9 @@ CAPSTONE_EXPORT bool CAPSTONE_API cs_disasm_iter(csh ud, const uint8_t **code, size_t *size, uint64_t *address, cs_insn *insn) { + if (*size == 0) + return false; + struct cs_struct *handle; uint16_t insn_size; MCInst mci;